Skip to content

Commit f547c1d

Browse files
authored
Move package metadata to own crate (#1150)
Branched from #1147 Progress towards #1148 Moves our existing package/library infra to a new `oak_package` crate. The main change is that NAMESPACE is no longer inspected with tree-sitter but with Rowan.
2 parents c1f33fc + ddad93d commit f547c1d

24 files changed

Lines changed: 286 additions & 198 deletions

Cargo.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ members = [
1515
"crates/echo",
1616
"crates/harp",
1717
"crates/libr",
18+
"crates/oak_core",
1819
"crates/oak_index",
20+
"crates/oak_package",
1921
"crates/stdext",
2022
]
2123

@@ -75,7 +77,9 @@ log = "0.4.18"
7577
mime_guess = "2.0.4"
7678
nix = { version = "0.26.2", features = ["signal"] }
7779
notify = "6.0.0"
80+
oak_core = { path = "crates/oak_core" }
7881
oak_index = { path = "crates/oak_index" }
82+
oak_package = { path = "crates/oak_package" }
7983
once_cell = "1.17.1"
8084
parking_lot = "0.12.3"
8185
paste = "1.0.14"

crates/ark/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ log.workspace = true
4444
mime_guess.workspace = true
4545
nix.workspace = true
4646
notify.workspace = true
47+
oak_package.workspace = true
4748
once_cell.workspace = true
4849
regex.workspace = true
4950
reqwest.workspace = true
@@ -76,6 +77,7 @@ yaml-rust.workspace = true
7677
ark_test.workspace = true
7778
assert_matches.workspace = true
7879
insta.workspace = true
80+
oak_package = { workspace = true, features = ["testing"] }
7981
stdext = { workspace = true, features = ["testing"] }
8082
tempfile.workspace = true
8183

crates/ark/src/lsp/diagnostics.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use anyhow::bail;
1414
use anyhow::Result;
1515
use harp::syntax::is_valid_symbol;
1616
use harp::syntax::sym_quote_invalid;
17+
use oak_package::library::Library;
18+
use oak_package::package::Package;
1719
use stdext::*;
1820
use tower_lsp::lsp_types::Diagnostic;
1921
use tower_lsp::lsp_types::DiagnosticSeverity;
@@ -26,8 +28,6 @@ use crate::lsp::declarations::top_level_declare;
2628
use crate::lsp::diagnostics_syntax::syntax_diagnostics;
2729
use crate::lsp::document::Document;
2830
use crate::lsp::indexer;
29-
use crate::lsp::inputs::library::Library;
30-
use crate::lsp::inputs::package::Package;
3131
use crate::lsp::inputs::source_root::SourceRoot;
3232
use crate::lsp::state::WorldState;
3333
use crate::lsp::traits::node::NodeExt;
@@ -1132,17 +1132,17 @@ mod tests {
11321132
use std::path::PathBuf;
11331133

11341134
use harp::eval::RParseEvalOptions;
1135+
use oak_package::library::Library;
1136+
use oak_package::package::Package;
1137+
use oak_package::package_description::Dcf;
1138+
use oak_package::package_description::Description;
1139+
use oak_package::package_namespace::Namespace;
11351140
use once_cell::sync::Lazy;
11361141
use tower_lsp::lsp_types;
11371142
use tower_lsp::lsp_types::Position;
11381143

11391144
use crate::console::console_inputs;
11401145
use crate::lsp::document::Document;
1141-
use crate::lsp::inputs::library::Library;
1142-
use crate::lsp::inputs::package::Package;
1143-
use crate::lsp::inputs::package_description::Dcf;
1144-
use crate::lsp::inputs::package_description::Description;
1145-
use crate::lsp::inputs::package_namespace::Namespace;
11461146
use crate::lsp::state::WorldState;
11471147
use crate::r_task;
11481148

@@ -1845,7 +1845,7 @@ foo
18451845
#[test]
18461846
fn test_penguins_symbol_no_diagnostic() {
18471847
r_task(|| {
1848-
let palmerpenguins_dir = crate::lsp::inputs::package::temp_palmerpenguin();
1848+
let palmerpenguins_dir = oak_package::package::temp_palmerpenguin();
18491849
let palmerpenguins_pkg = Package::load_from_folder(palmerpenguins_dir.path())
18501850
.unwrap()
18511851
.unwrap();

crates/ark/src/lsp/diagnostics_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ fn new_syntax_diagnostic(
427427

428428
#[cfg(test)]
429429
mod tests {
430+
use oak_package::library::Library;
430431
use tower_lsp::lsp_types::Diagnostic;
431432
use tower_lsp::lsp_types::Position;
432433

433434
use crate::lsp::diagnostics::DiagnosticContext;
434435
use crate::lsp::diagnostics_syntax::syntax_diagnostics;
435436
use crate::lsp::document::Document;
436-
use crate::lsp::inputs::library::Library;
437437

438438
fn text_diagnostics(text: &str) -> Vec<Diagnostic> {
439439
let document = Document::new(text, None);

crates/ark/src/lsp/inputs.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
//
2-
// mod.rs
3-
//
4-
// Copyright (C) 2025 by Posit Software, PBC
5-
//
6-
//
7-
8-
pub mod library;
9-
pub mod package;
10-
pub mod package_description;
11-
pub mod package_index;
12-
pub mod package_namespace;
131
pub mod source_root;

crates/ark/src/lsp/inputs/source_root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
//
77

8-
use super::package::Package;
8+
use oak_package::package::Package;
99

1010
/// The root of a source tree.
1111
/// Currently only supports packages, but can be extended to scripts.

crates/ark/src/lsp/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::sync::RwLock;
1818
use anyhow::anyhow;
1919
use futures::stream::FuturesUnordered;
2020
use futures::StreamExt;
21+
use oak_package::library::Library;
2122
use tokio::sync::mpsc;
2223
use tokio::sync::mpsc::unbounded_channel as tokio_unbounded_channel;
2324
use tokio::task;
@@ -41,7 +42,6 @@ use crate::lsp::diagnostics::generate_diagnostics;
4142
use crate::lsp::document::Document;
4243
use crate::lsp::handlers;
4344
use crate::lsp::indexer;
44-
use crate::lsp::inputs::library::Library;
4545
use crate::lsp::state::WorldState;
4646
use crate::lsp::state_handlers;
4747
use crate::lsp::state_handlers::ConsoleInputs;

crates/ark/src/lsp/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::collections::HashMap;
22
use std::path::Path;
33

44
use anyhow::anyhow;
5+
use oak_package::library::Library;
56
use url::Url;
67

78
use crate::lsp::config::LspConfig;
89
use crate::lsp::document::Document;
9-
use crate::lsp::inputs::library::Library;
1010
use crate::lsp::inputs::source_root::SourceRoot;
1111

1212
#[derive(Clone, Default, Debug)]

crates/ark/src/lsp/state_handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
use anyhow::anyhow;
9+
use oak_package::package::Package;
910
use stdext::result::ResultExt;
1011
use tower_lsp::lsp_types;
1112
use tower_lsp::lsp_types::CompletionOptions;
@@ -51,7 +52,6 @@ use crate::lsp::config::indent_style_from_lsp;
5152
use crate::lsp::config::DOCUMENT_SETTINGS;
5253
use crate::lsp::config::GLOBAL_SETTINGS;
5354
use crate::lsp::document::Document;
54-
use crate::lsp::inputs::package::Package;
5555
use crate::lsp::inputs::source_root::SourceRoot;
5656
use crate::lsp::main_loop::DidCloseVirtualDocumentParams;
5757
use crate::lsp::main_loop::DidOpenVirtualDocumentParams;

0 commit comments

Comments
 (0)