diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-01 10:53:17 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-01 10:53:17 +0000 |
commit | f6f9a0bf35f073e554a340f04e213867732d81a1 (patch) | |
tree | 9c9cfc3f6868864d7dd1164aaff6b248f81a402b /crates/ra_analysis/src/imp.rs | |
parent | d685a9b564fe524865cda5713c527aaeb1ca6b1d (diff) | |
parent | f2b654fd443ce1a0a31a9eaf1a1c25e911d0001a (diff) |
Merge #182
182: Module source r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 0744ea9c8..060e2b606 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | db::{self, FileSyntaxQuery, SyntaxDatabase}, | 20 | db::{self, FileSyntaxQuery, SyntaxDatabase}, |
21 | descriptors::{ | 21 | descriptors::{ |
22 | function::{FnDescriptor, FnId}, | 22 | function::{FnDescriptor, FnId}, |
23 | module::{ModuleTree, Problem}, | 23 | module::{ModuleSource, ModuleTree, Problem}, |
24 | DeclarationDescriptor, DescriptorDatabase, | 24 | DeclarationDescriptor, DescriptorDatabase, |
25 | }, | 25 | }, |
26 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, | 26 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, |
@@ -222,9 +222,15 @@ impl AnalysisImpl { | |||
222 | .into_iter() | 222 | .into_iter() |
223 | .filter_map(|module_id| { | 223 | .filter_map(|module_id| { |
224 | let link = module_id.parent_link(&module_tree)?; | 224 | let link = module_id.parent_link(&module_tree)?; |
225 | let file_id = link.owner(&module_tree).file_id(&module_tree); | 225 | let file_id = match link.owner(&module_tree).source(&module_tree) { |
226 | let syntax = self.db.file_syntax(file_id); | 226 | ModuleSource::File(file_id) => file_id, |
227 | let decl = link.bind_source(&module_tree, syntax.ast()); | 227 | ModuleSource::Inline(..) => { |
228 | //TODO: https://github.com/rust-analyzer/rust-analyzer/issues/181 | ||
229 | return None; | ||
230 | } | ||
231 | }; | ||
232 | let decl = link.bind_source(&module_tree, &self.db); | ||
233 | let decl = decl.ast(); | ||
228 | 234 | ||
229 | let sym = FileSymbol { | 235 | let sym = FileSymbol { |
230 | name: decl.name().unwrap().text(), | 236 | name: decl.name().unwrap().text(), |
@@ -243,7 +249,7 @@ impl AnalysisImpl { | |||
243 | .modules_for_file(file_id) | 249 | .modules_for_file(file_id) |
244 | .into_iter() | 250 | .into_iter() |
245 | .map(|it| it.root(&module_tree)) | 251 | .map(|it| it.root(&module_tree)) |
246 | .map(|it| it.file_id(&module_tree)) | 252 | .filter_map(|it| it.source(&module_tree).as_file()) |
247 | .filter_map(|it| crate_graph.crate_id_for_crate_root(it)) | 253 | .filter_map(|it| crate_graph.crate_id_for_crate_root(it)) |
248 | .collect(); | 254 | .collect(); |
249 | 255 | ||
@@ -365,7 +371,7 @@ impl AnalysisImpl { | |||
365 | }) | 371 | }) |
366 | .collect::<Vec<_>>(); | 372 | .collect::<Vec<_>>(); |
367 | if let Some(m) = module_tree.any_module_for_file(file_id) { | 373 | if let Some(m) = module_tree.any_module_for_file(file_id) { |
368 | for (name_node, problem) in m.problems(&module_tree, syntax.ast()) { | 374 | for (name_node, problem) in m.problems(&module_tree, &self.db) { |
369 | let diag = match problem { | 375 | let diag = match problem { |
370 | Problem::UnresolvedModule { candidate } => { | 376 | Problem::UnresolvedModule { candidate } => { |
371 | let create_file = FileSystemEdit::CreateFile { | 377 | let create_file = FileSystemEdit::CreateFile { |
@@ -533,7 +539,7 @@ impl AnalysisImpl { | |||
533 | }; | 539 | }; |
534 | module_id | 540 | module_id |
535 | .child(module_tree, name.as_str()) | 541 | .child(module_tree, name.as_str()) |
536 | .map(|it| it.file_id(module_tree)) | 542 | .and_then(|it| it.source(&module_tree).as_file()) |
537 | .into_iter() | 543 | .into_iter() |
538 | .collect() | 544 | .collect() |
539 | } | 545 | } |