aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_analysis/src/imp.rs3
-rw-r--r--crates/ra_analysis/src/lib.rs5
-rw-r--r--crates/ra_analysis/tests/tests.rs10
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
4 files changed, 13 insertions, 7 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 7604c7def..b812c3441 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -121,6 +121,7 @@ impl db::RootDatabase {
121 name: decl_name.text(), 121 name: decl_name.text(),
122 range: decl_name.syntax().range(), 122 range: decl_name.syntax().range(),
123 kind: MODULE, 123 kind: MODULE,
124 ptr: None,
124 }]) 125 }])
125 } 126 }
126 /// Returns `Vec` for the same reason as `parent_module` 127 /// Returns `Vec` for the same reason as `parent_module`
@@ -158,6 +159,7 @@ impl db::RootDatabase {
158 name: entry.name().to_string().into(), 159 name: entry.name().to_string().into(),
159 range: entry.ptr().range(), 160 range: entry.ptr().range(),
160 kind: NAME, 161 kind: NAME,
162 ptr: None,
161 }); 163 });
162 return Ok(Some(rr)); 164 return Ok(Some(rr));
163 }; 165 };
@@ -185,6 +187,7 @@ impl db::RootDatabase {
185 name, 187 name,
186 range: TextRange::offset_len(0.into(), 0.into()), 188 range: TextRange::offset_len(0.into(), 0.into()),
187 kind: MODULE, 189 kind: MODULE,
190 ptr: None,
188 }; 191 };
189 rr.resolves_to.push(symbol); 192 rr.resolves_to.push(symbol);
190 return Ok(Some(rr)); 193 return Ok(Some(rr));
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 69d6754d6..343fd28bb 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -41,7 +41,7 @@ pub use ra_editor::{
41pub use hir::FnSignatureInfo; 41pub use hir::FnSignatureInfo;
42 42
43pub use ra_db::{ 43pub use ra_db::{
44 Canceled, Cancelable, FilePosition, FileRange, 44 Canceled, Cancelable, FilePosition, FileRange, LocalSyntaxPtr,
45 CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase 45 CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase
46}; 46};
47 47
@@ -225,6 +225,8 @@ pub struct NavigationTarget {
225 name: SmolStr, 225 name: SmolStr,
226 kind: SyntaxKind, 226 kind: SyntaxKind,
227 range: TextRange, 227 range: TextRange,
228 // Should be DefId ideally
229 ptr: Option<LocalSyntaxPtr>,
228} 230}
229 231
230impl NavigationTarget { 232impl NavigationTarget {
@@ -234,6 +236,7 @@ impl NavigationTarget {
234 kind: symbol.ptr.kind(), 236 kind: symbol.ptr.kind(),
235 file_id, 237 file_id,
236 range: symbol.ptr.range(), 238 range: symbol.ptr.range(),
239 ptr: Some(symbol.ptr.clone()),
237 } 240 }
238 } 241 }
239 pub fn name(&self) -> &SmolStr { 242 pub fn name(&self) -> &SmolStr {
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index 3045c2e78..bcf29d29c 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -25,7 +25,7 @@ fn approximate_resolve_works_in_items() {
25 assert_eq_dbg( 25 assert_eq_dbg(
26 r#"ReferenceResolution { 26 r#"ReferenceResolution {
27 reference_range: [23; 26), 27 reference_range: [23; 26),
28 resolves_to: [NavigationTarget { file_id: FileId(1), symbol: FileSymbol { name: "Foo", node_range: [0; 11), kind: STRUCT_DEF } }] 28 resolves_to: [NavigationTarget { file_id: FileId(1), name: "Foo", kind: STRUCT_DEF, range: [0; 11), ptr: Some(LocalSyntaxPtr { range: [0; 11), kind: STRUCT_DEF }) }]
29 }"#, 29 }"#,
30 &symbols, 30 &symbols,
31 ); 31 );
@@ -46,7 +46,7 @@ fn test_resolve_module() {
46 assert_eq_dbg( 46 assert_eq_dbg(
47 r#"ReferenceResolution { 47 r#"ReferenceResolution {
48 reference_range: [4; 7), 48 reference_range: [4; 7),
49 resolves_to: [NavigationTarget { file_id: FileId(2), symbol: FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE } }] 49 resolves_to: [NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]
50 }"#, 50 }"#,
51 &symbols, 51 &symbols,
52 ); 52 );
@@ -64,7 +64,7 @@ fn test_resolve_module() {
64 assert_eq_dbg( 64 assert_eq_dbg(
65 r#"ReferenceResolution { 65 r#"ReferenceResolution {
66 reference_range: [4; 7), 66 reference_range: [4; 7),
67 resolves_to: [NavigationTarget { file_id: FileId(2), symbol: FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE } }] 67 resolves_to: [NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]
68 }"#, 68 }"#,
69 &symbols, 69 &symbols,
70 ); 70 );
@@ -107,7 +107,7 @@ fn test_resolve_parent_module() {
107 ); 107 );
108 let symbols = analysis.parent_module(pos).unwrap(); 108 let symbols = analysis.parent_module(pos).unwrap();
109 assert_eq_dbg( 109 assert_eq_dbg(
110 r#"[NavigationTarget { file_id: FileId(1), symbol: FileSymbol { name: "foo", node_range: [4; 7), kind: MODULE } }]"#, 110 r#"[NavigationTarget { file_id: FileId(1), name: "foo", kind: MODULE, range: [4; 7), ptr: None }]"#,
111 &symbols, 111 &symbols,
112 ); 112 );
113} 113}
@@ -126,7 +126,7 @@ fn test_resolve_parent_module_for_inline() {
126 ); 126 );
127 let symbols = analysis.parent_module(pos).unwrap(); 127 let symbols = analysis.parent_module(pos).unwrap();
128 assert_eq_dbg( 128 assert_eq_dbg(
129 r#"[NavigationTarget { file_id: FileId(1), symbol: FileSymbol { name: "bar", node_range: [18; 21), kind: MODULE } }]"#, 129 r#"[NavigationTarget { file_id: FileId(1), name: "bar", kind: MODULE, range: [18; 21), ptr: None }]"#,
130 &symbols, 130 &symbols,
131 ); 131 );
132} 132}
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 26b6c7d8a..b5792f3b8 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -190,7 +190,7 @@ pub fn handle_workspace_symbol(
190 let mut res = Vec::new(); 190 let mut res = Vec::new();
191 for nav in world.analysis().symbol_search(query)? { 191 for nav in world.analysis().symbol_search(query)? {
192 let info = SymbolInformation { 192 let info = SymbolInformation {
193 name: nav.name().into(), 193 name: nav.name().to_string(),
194 kind: nav.kind().conv(), 194 kind: nav.kind().conv(),
195 location: nav.try_conv_with(world)?, 195 location: nav.try_conv_with(world)?,
196 container_name: None, 196 container_name: None,