Merge #2139
2139: move mod_resolution to hir_def r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
51092ee72a
@ -49,7 +49,6 @@
|
||||
|
||||
mod per_ns;
|
||||
mod collector;
|
||||
mod mod_resolution;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
//! FIXME: write short doc here
|
||||
|
||||
use hir_def::{attr::Attr, nameres::raw};
|
||||
use hir_def::{
|
||||
attr::Attr,
|
||||
nameres::{mod_resolution::ModDir, raw},
|
||||
};
|
||||
use hir_expand::name;
|
||||
use ra_cfg::CfgOptions;
|
||||
use ra_db::FileId;
|
||||
@ -12,8 +15,8 @@ use crate::{
|
||||
db::DefDatabase,
|
||||
ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
|
||||
nameres::{
|
||||
diagnostics::DefDiagnostic, mod_resolution::ModDir, Crate, CrateDefMap, CrateModuleId,
|
||||
ModuleData, ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode,
|
||||
diagnostics::DefDiagnostic, Crate, CrateDefMap, CrateModuleId, ModuleData, ModuleDef,
|
||||
PerNs, ReachedFixedPoint, Resolution, ResolveMode,
|
||||
},
|
||||
Adt, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, PathKind, Static,
|
||||
Struct, Trait, TypeAlias, Union,
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! FIXME: write short doc here
|
||||
|
||||
// FIXME: review privacy of submodules
|
||||
pub mod raw;
|
||||
pub mod mod_resolution;
|
||||
|
@ -1,12 +1,13 @@
|
||||
//! This module resolves `mod foo;` declaration to file.
|
||||
use hir_expand::name::Name;
|
||||
use ra_db::FileId;
|
||||
use ra_syntax::SmolStr;
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{db::DefDatabase, HirFileId, Name};
|
||||
use crate::{db::DefDatabase2, HirFileId};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct ModDir {
|
||||
pub struct ModDir {
|
||||
/// `.` for `mod.rs`, `lib.rs`
|
||||
/// `./foo` for `foo.rs`
|
||||
/// `./foo/bar` for `mod bar { mod x; }` nested in `foo.rs`
|
||||
@ -16,15 +17,11 @@ pub(super) struct ModDir {
|
||||
}
|
||||
|
||||
impl ModDir {
|
||||
pub(super) fn root() -> ModDir {
|
||||
pub fn root() -> ModDir {
|
||||
ModDir { path: RelativePathBuf::default(), root_non_dir_owner: false }
|
||||
}
|
||||
|
||||
pub(super) fn descend_into_definition(
|
||||
&self,
|
||||
name: &Name,
|
||||
attr_path: Option<&SmolStr>,
|
||||
) -> ModDir {
|
||||
pub fn descend_into_definition(&self, name: &Name, attr_path: Option<&SmolStr>) -> ModDir {
|
||||
let mut path = self.path.clone();
|
||||
match attr_to_path(attr_path) {
|
||||
None => path.push(&name.to_string()),
|
||||
@ -38,9 +35,9 @@ impl ModDir {
|
||||
ModDir { path, root_non_dir_owner: false }
|
||||
}
|
||||
|
||||
pub(super) fn resolve_declaration(
|
||||
pub fn resolve_declaration(
|
||||
&self,
|
||||
db: &impl DefDatabase,
|
||||
db: &impl DefDatabase2,
|
||||
file_id: HirFileId,
|
||||
name: &Name,
|
||||
attr_path: Option<&SmolStr>,
|
Loading…
x
Reference in New Issue
Block a user