diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-15 20:25:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-15 20:25:53 +0000 |
commit | 920848940ae7b79b1655ac48a9e2c1694b9e06c8 (patch) | |
tree | cd0d39cd13ae0a9ee7299db575bea1a854cc0102 /crates/ra_hir_def | |
parent | 86469d4195e7aeb93ae420d0c073593bfccc97f0 (diff) | |
parent | 4c90b7e2ecd03e739a3c92bbe5afd4c90fe2812d (diff) |
Merge #2266
2266: Sourcify some things r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-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 | } |