aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/nameres.rs1
-rw-r--r--crates/ra_hir/src/nameres/collector.rs9
-rw-r--r--crates/ra_hir_def/src/nameres.rs2
-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
50mod per_ns; 50mod per_ns;
51mod collector; 51mod collector;
52mod mod_resolution;
53#[cfg(test)] 52#[cfg(test)]
54mod tests; 53mod 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
3use hir_def::{attr::Attr, nameres::raw}; 3use hir_def::{
4 attr::Attr,
5 nameres::{mod_resolution::ModDir, raw},
6};
4use hir_expand::name; 7use hir_expand::name;
5use ra_cfg::CfgOptions; 8use ra_cfg::CfgOptions;
6use ra_db::FileId; 9use 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
3pub mod raw; 4pub mod raw;
5pub 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.
2use hir_expand::name::Name;
2use ra_db::FileId; 3use ra_db::FileId;
3use ra_syntax::SmolStr; 4use ra_syntax::SmolStr;
4use relative_path::RelativePathBuf; 5use relative_path::RelativePathBuf;
5 6
6use crate::{db::DefDatabase, HirFileId, Name}; 7use crate::{db::DefDatabase2, HirFileId};
7 8
8#[derive(Clone, Debug)] 9#[derive(Clone, Debug)]
9pub(super) struct ModDir { 10pub 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
18impl ModDir { 19impl 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>,