diff options
author | Aleksey Kladov <[email protected]> | 2019-11-15 20:24:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-15 20:24:56 +0000 |
commit | 4c90b7e2ecd03e739a3c92bbe5afd4c90fe2812d (patch) | |
tree | 3f95c69830b973c86362586dcbc25831996dfe98 /crates/ra_hir_def/src/lib.rs | |
parent | 1889b3c7b52c1070734dc449d4119c5e5cf991a4 (diff) |
Sourcify some things
If we want to support macros properly, we need to get rid of those
FileIds everywhere...
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 0a59c4ad7..a240a10b8 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -78,14 +78,13 @@ impl ModuleSource { | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | pub fn from_child_node( | 81 | pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { |
82 | db: &impl db::DefDatabase2, | 82 | if let Some(m) = |
83 | file_id: FileId, | 83 | child.ast.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) |
84 | child: &SyntaxNode, | 84 | { |
85 | ) -> ModuleSource { | ||
86 | if let Some(m) = child.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) { | ||
87 | ModuleSource::Module(m) | 85 | ModuleSource::Module(m) |
88 | } else { | 86 | } else { |
87 | let file_id = child.file_id.original_file(db); | ||
89 | let source_file = db.parse(file_id).tree(); | 88 | let source_file = db.parse(file_id).tree(); |
90 | ModuleSource::SourceFile(source_file) | 89 | ModuleSource::SourceFile(source_file) |
91 | } | 90 | } |