diff options
-rw-r--r-- | crates/libanalysis/src/lib.rs | 28 | ||||
-rw-r--r-- | crates/libeditor/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/libeditor/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/libeditor/src/symbols.rs | 3 | ||||
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 3 |
5 files changed, 20 insertions, 16 deletions
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 15a433afc..63c4c77cf 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -26,7 +26,7 @@ use std::{ | |||
26 | }; | 26 | }; |
27 | 27 | ||
28 | use libsyntax2::{ | 28 | use libsyntax2::{ |
29 | TextUnit, TextRange, | 29 | TextUnit, TextRange, SmolStr, |
30 | ast::{self, AstNode, NameOwner, ParsedFile}, | 30 | ast::{self, AstNode, NameOwner, ParsedFile}, |
31 | SyntaxKind::*, | 31 | SyntaxKind::*, |
32 | }; | 32 | }; |
@@ -144,7 +144,21 @@ impl World { | |||
144 | if let Some(name) = find_node::<ast::Name>(syntax, offset) { | 144 | if let Some(name) = find_node::<ast::Name>(syntax, offset) { |
145 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | 145 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { |
146 | if module.has_semi() { | 146 | if module.has_semi() { |
147 | return Ok(self.resolve_module(id, module)); | 147 | let file_ids = self.resolve_module(id, module); |
148 | |||
149 | let res = file_ids.into_iter().map(|id| { | ||
150 | let name = module.name() | ||
151 | .map(|n| n.text()) | ||
152 | .unwrap_or_else(|| SmolStr::new("")); | ||
153 | let symbol = FileSymbol { | ||
154 | name, | ||
155 | node_range: TextRange::offset_len(0.into(), 0.into()), | ||
156 | kind: MODULE, | ||
157 | }; | ||
158 | (id, symbol) | ||
159 | }).collect(); | ||
160 | |||
161 | return Ok(res); | ||
148 | } | 162 | } |
149 | } | 163 | } |
150 | } | 164 | } |
@@ -159,7 +173,7 @@ impl World { | |||
159 | self.world_symbols(query) | 173 | self.world_symbols(query) |
160 | } | 174 | } |
161 | 175 | ||
162 | fn resolve_module(&self, id: FileId, module: ast::Module) -> Vec<(FileId, FileSymbol)> { | 176 | fn resolve_module(&self, id: FileId, module: ast::Module) -> Vec<FileId> { |
163 | let name = match module.name() { | 177 | let name = match module.name() { |
164 | Some(name) => name.text(), | 178 | Some(name) => name.text(), |
165 | None => return Vec::new(), | 179 | None => return Vec::new(), |
@@ -170,14 +184,6 @@ impl World { | |||
170 | ]; | 184 | ]; |
171 | paths.iter() | 185 | paths.iter() |
172 | .filter_map(|path| self.resolve_relative_path(id, path)) | 186 | .filter_map(|path| self.resolve_relative_path(id, path)) |
173 | .map(|id| { | ||
174 | let symbol = FileSymbol { | ||
175 | name: name.clone(), | ||
176 | node_range: TextRange::offset_len(0.into(), 0.into()), | ||
177 | kind: MODULE, | ||
178 | }; | ||
179 | (id, symbol) | ||
180 | }) | ||
181 | .collect() | 187 | .collect() |
182 | } | 188 | } |
183 | 189 | ||
diff --git a/crates/libeditor/Cargo.toml b/crates/libeditor/Cargo.toml index 7b39870cd..55f41c2c5 100644 --- a/crates/libeditor/Cargo.toml +++ b/crates/libeditor/Cargo.toml | |||
@@ -9,7 +9,6 @@ itertools = "0.7.8" | |||
9 | superslice = "0.1.0" | 9 | superslice = "0.1.0" |
10 | 10 | ||
11 | libsyntax2 = { path = "../libsyntax2" } | 11 | libsyntax2 = { path = "../libsyntax2" } |
12 | smol_str = "0.1.0" | ||
13 | 12 | ||
14 | [dev-dependencies] | 13 | [dev-dependencies] |
15 | assert_eq_text = { path = "../assert_eq_text" } | 14 | assert_eq_text = { path = "../assert_eq_text" } |
diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index d9d0369f6..abd104af2 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | extern crate libsyntax2; | 1 | extern crate libsyntax2; |
2 | extern crate superslice; | 2 | extern crate superslice; |
3 | extern crate itertools; | 3 | extern crate itertools; |
4 | extern crate smol_str; | ||
5 | 4 | ||
6 | mod extend_selection; | 5 | mod extend_selection; |
7 | mod symbols; | 6 | mod symbols; |
diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index d7bd111e6..b2b05bc6a 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use smol_str::SmolStr; | ||
2 | use libsyntax2::{ | 1 | use libsyntax2::{ |
3 | SyntaxKind, SyntaxNodeRef, AstNode, ParsedFile, | 2 | SyntaxKind, SyntaxNodeRef, AstNode, ParsedFile, SmolStr, |
4 | ast::{self, NameOwner}, | 3 | ast::{self, NameOwner}, |
5 | algo::{ | 4 | algo::{ |
6 | visit::{visitor, Visitor}, | 5 | visit::{visitor, Visitor}, |
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs index e837a8d2d..c078baa3a 100644 --- a/crates/libsyntax2/src/lib.rs +++ b/crates/libsyntax2/src/lib.rs | |||
@@ -41,10 +41,11 @@ mod yellow; | |||
41 | pub mod utils; | 41 | pub mod utils; |
42 | 42 | ||
43 | pub use { | 43 | pub use { |
44 | text_unit::{TextRange, TextUnit}, | ||
45 | smol_str::SmolStr, | ||
44 | ast::{AstNode, ParsedFile}, | 46 | ast::{AstNode, ParsedFile}, |
45 | lexer::{tokenize, Token}, | 47 | lexer::{tokenize, Token}, |
46 | syntax_kinds::SyntaxKind, | 48 | syntax_kinds::SyntaxKind, |
47 | text_unit::{TextRange, TextUnit}, | ||
48 | yellow::{SyntaxNode, SyntaxNodeRef, OwnedRoot, RefRoot, TreeRoot, SyntaxError}, | 49 | yellow::{SyntaxNode, SyntaxNodeRef, OwnedRoot, RefRoot, TreeRoot, SyntaxError}, |
49 | }; | 50 | }; |
50 | 51 | ||