File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
crates/ark/src/lsp/inputs Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use crate::lsp::inputs::package_namespace::Namespace;
14
14
/// Represents an R package and its metadata relevant for static analysis.
15
15
#[ derive( Clone , Debug ) ]
16
16
pub struct Package {
17
- /// Path to the directory that contains `DESCRIPTION` and `NAMESPACE `. Can
17
+ /// Path to the directory that contains `DESCRIPTION``. Can
18
18
/// be an installed package or a package source.
19
19
pub path : PathBuf ,
20
20
@@ -47,11 +47,16 @@ impl Package {
47
47
) ) ;
48
48
}
49
49
50
- let namespace_contents = fs:: read_to_string ( & namespace_path) ?;
51
- let namespace = Namespace :: parse ( & namespace_contents) ?;
50
+ let namespace = if namespace_path. is_file ( ) {
51
+ let namespace_contents = fs:: read_to_string ( & namespace_path) ?;
52
+ Namespace :: parse ( & namespace_contents) ?
53
+ } else {
54
+ tracing:: info!( "Package `{name}` doesn't contain a NAMESPACE file, using defaults" ) ;
55
+ Namespace :: default ( )
56
+ } ;
52
57
53
58
Ok ( Some ( Package {
54
- path : package_path. to_path_buf ( ) ,
59
+ path : package_path,
55
60
description,
56
61
namespace,
57
62
} ) )
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use tree_sitter::Parser;
9
9
use crate :: treesitter:: TSQuery ;
10
10
11
11
/// Parsed NAMESPACE file
12
- #[ derive( Clone , Debug ) ]
12
+ #[ derive( Default , Clone , Debug ) ]
13
13
pub struct Namespace {
14
14
/// Names of objects exported with `export()`
15
15
pub exports : Vec < String > ,
You can’t perform that action at this time.
0 commit comments