diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/mod_resolution.rs (renamed from crates/ra_hir/src/nameres/mod_resolution.rs) | 17 |
4 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 39f585b44..7c4d07de0 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -49,7 +49,6 @@ | |||
49 | 49 | ||
50 | mod per_ns; | 50 | mod per_ns; |
51 | mod collector; | 51 | mod collector; |
52 | mod mod_resolution; | ||
53 | #[cfg(test)] | 52 | #[cfg(test)] |
54 | mod tests; | 53 | mod tests; |
55 | 54 | ||
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index e2e13805a..ee0a4c99f 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -1,6 +1,9 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir_def::{attr::Attr, nameres::raw}; | 3 | use hir_def::{ |
4 | attr::Attr, | ||
5 | nameres::{mod_resolution::ModDir, raw}, | ||
6 | }; | ||
4 | use hir_expand::name; | 7 | use hir_expand::name; |
5 | use ra_cfg::CfgOptions; | 8 | use ra_cfg::CfgOptions; |
6 | use ra_db::FileId; | 9 | use ra_db::FileId; |
@@ -12,8 +15,8 @@ use crate::{ | |||
12 | db::DefDatabase, | 15 | db::DefDatabase, |
13 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, | 16 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, |
14 | nameres::{ | 17 | nameres::{ |
15 | diagnostics::DefDiagnostic, mod_resolution::ModDir, Crate, CrateDefMap, CrateModuleId, | 18 | diagnostics::DefDiagnostic, Crate, CrateDefMap, CrateModuleId, ModuleData, ModuleDef, |
16 | ModuleData, ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode, | 19 | PerNs, ReachedFixedPoint, Resolution, ResolveMode, |
17 | }, | 20 | }, |
18 | Adt, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, PathKind, Static, | 21 | Adt, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, PathKind, Static, |
19 | Struct, Trait, TypeAlias, Union, | 22 | Struct, Trait, TypeAlias, Union, |
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 5893708e8..11ba8a777 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | // FIXME: review privacy of submodules | ||
3 | pub mod raw; | 4 | pub mod raw; |
5 | pub mod mod_resolution; | ||
diff --git a/crates/ra_hir/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index 334cdd692..7d7e2779a 100644 --- a/crates/ra_hir/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs | |||
@@ -1,12 +1,13 @@ | |||
1 | //! This module resolves `mod foo;` declaration to file. | 1 | //! This module resolves `mod foo;` declaration to file. |
2 | use hir_expand::name::Name; | ||
2 | use ra_db::FileId; | 3 | use ra_db::FileId; |
3 | use ra_syntax::SmolStr; | 4 | use ra_syntax::SmolStr; |
4 | use relative_path::RelativePathBuf; | 5 | use relative_path::RelativePathBuf; |
5 | 6 | ||
6 | use crate::{db::DefDatabase, HirFileId, Name}; | 7 | use crate::{db::DefDatabase2, HirFileId}; |
7 | 8 | ||
8 | #[derive(Clone, Debug)] | 9 | #[derive(Clone, Debug)] |
9 | pub(super) struct ModDir { | 10 | pub struct ModDir { |
10 | /// `.` for `mod.rs`, `lib.rs` | 11 | /// `.` for `mod.rs`, `lib.rs` |
11 | /// `./foo` for `foo.rs` | 12 | /// `./foo` for `foo.rs` |
12 | /// `./foo/bar` for `mod bar { mod x; }` nested in `foo.rs` | 13 | /// `./foo/bar` for `mod bar { mod x; }` nested in `foo.rs` |
@@ -16,15 +17,11 @@ pub(super) struct ModDir { | |||
16 | } | 17 | } |
17 | 18 | ||
18 | impl ModDir { | 19 | impl ModDir { |
19 | pub(super) fn root() -> ModDir { | 20 | pub fn root() -> ModDir { |
20 | ModDir { path: RelativePathBuf::default(), root_non_dir_owner: false } | 21 | ModDir { path: RelativePathBuf::default(), root_non_dir_owner: false } |
21 | } | 22 | } |
22 | 23 | ||
23 | pub(super) fn descend_into_definition( | 24 | pub fn descend_into_definition(&self, name: &Name, attr_path: Option<&SmolStr>) -> ModDir { |
24 | &self, | ||
25 | name: &Name, | ||
26 | attr_path: Option<&SmolStr>, | ||
27 | ) -> ModDir { | ||
28 | let mut path = self.path.clone(); | 25 | let mut path = self.path.clone(); |
29 | match attr_to_path(attr_path) { | 26 | match attr_to_path(attr_path) { |
30 | None => path.push(&name.to_string()), | 27 | None => path.push(&name.to_string()), |
@@ -38,9 +35,9 @@ impl ModDir { | |||
38 | ModDir { path, root_non_dir_owner: false } | 35 | ModDir { path, root_non_dir_owner: false } |
39 | } | 36 | } |
40 | 37 | ||
41 | pub(super) fn resolve_declaration( | 38 | pub fn resolve_declaration( |
42 | &self, | 39 | &self, |
43 | db: &impl DefDatabase, | 40 | db: &impl DefDatabase2, |
44 | file_id: HirFileId, | 41 | file_id: HirFileId, |
45 | name: &Name, | 42 | name: &Name, |
46 | attr_path: Option<&SmolStr>, | 43 | attr_path: Option<&SmolStr>, |