aboutsummaryrefslogtreecommitdiff
path: root/crates/libanalysis/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-18 10:42:28 +0100
committerAleksey Kladov <[email protected]>2018-08-18 10:42:28 +0100
commit4d8be265849c55912467961e09af657176472dcb (patch)
tree6d1808a89a57db69211a1dd5d4f25c4650da10d7 /crates/libanalysis/src
parenta5eeef0eeed092cb663afc3b0cda2c0df0c7e793 (diff)
refactor
Diffstat (limited to 'crates/libanalysis/src')
-rw-r--r--crates/libanalysis/src/lib.rs28
1 files changed, 17 insertions, 11 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
28use libsyntax2::{ 28use 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