diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-05 13:38:39 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-05 13:38:39 +0000 |
commit | 4c0bd068da39e74c66104206e27c270454e3562e (patch) | |
tree | 25e6c7005e04c3a63344f23a003614409cfda4c9 /crates/ra_hir/src/code_model/src.rs | |
parent | ace661bb10dbfd596a444c235f80fa43a2845239 (diff) | |
parent | d15f300268fa955f8e9c04d51ca1dc528766f742 (diff) |
Merge #2474
2474: Move `ModuleSource`, create `ModuleOrigin` r=matklad a=ice1000
As title. This comes right after #2473
Co-authored-by: ice1000 <[email protected]>
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 {}`. |