diff options
Diffstat (limited to 'crates/ra_hir/src/code_model/src.rs')
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 36cfbc8f1..d9bccd902 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use either::Either; | 3 | use either::Either; |
4 | use hir_def::{ | 4 | use hir_def::{ |
5 | nameres::ModuleSource, | ||
5 | src::{HasChildSource, HasSource as _}, | 6 | src::{HasChildSource, HasSource as _}, |
6 | AstItemDef, Lookup, VariantId, | 7 | AstItemDef, Lookup, VariantId, |
7 | }; | 8 | }; |
@@ -9,7 +10,7 @@ use ra_syntax::ast; | |||
9 | 10 | ||
10 | use crate::{ | 11 | use crate::{ |
11 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, | 12 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, |
12 | Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, | 13 | Module, Static, Struct, StructField, Trait, TypeAlias, Union, |
13 | }; | 14 | }; |
14 | 15 | ||
15 | pub use hir_expand::InFile; | 16 | pub use hir_expand::InFile; |
@@ -25,11 +26,7 @@ impl Module { | |||
25 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. | 26 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. |
26 | pub fn definition_source(self, db: &impl DefDatabase) -> InFile<ModuleSource> { | 27 | pub fn definition_source(self, db: &impl DefDatabase) -> InFile<ModuleSource> { |
27 | let def_map = db.crate_def_map(self.id.krate); | 28 | let def_map = db.crate_def_map(self.id.krate); |
28 | let src = def_map[self.id.local_id].definition_source(db); | 29 | def_map[self.id.local_id].definition_source(db) |
29 | src.map(|it| match it { | ||
30 | Either::Left(it) => ModuleSource::SourceFile(it), | ||
31 | Either::Right(it) => ModuleSource::Module(it), | ||
32 | }) | ||
33 | } | 30 | } |
34 | 31 | ||
35 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | 32 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. |