mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Hide ImportId
This commit is contained in:
parent
3bdb034906
commit
e5bcb69e4f
4 changed files with 26 additions and 21 deletions
|
@ -9,7 +9,7 @@ use hir_def::{
|
|||
body::scope::ExprScopes,
|
||||
builtin_type::BuiltinType,
|
||||
docs::Documentation,
|
||||
nameres::per_ns::PerNs,
|
||||
nameres::{per_ns::PerNs, raw::ImportId},
|
||||
resolver::{HasResolver, TypeNs},
|
||||
type_ref::TypeRef,
|
||||
ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup,
|
||||
|
@ -30,7 +30,7 @@ use crate::{
|
|||
TypeAliasId,
|
||||
},
|
||||
ty::{InferenceResult, Namespace, TraitRef},
|
||||
Either, HasSource, ImportId, Name, Source, Ty,
|
||||
Either, HasSource, Name, Source, Ty,
|
||||
};
|
||||
|
||||
/// hir::Crate describes a single crate. It's the main interface with which
|
||||
|
@ -129,17 +129,6 @@ impl Module {
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns the syntax of the last path segment corresponding to this import
|
||||
pub fn import_source(
|
||||
self,
|
||||
db: &impl HirDatabase,
|
||||
import: ImportId,
|
||||
) -> Either<ast::UseTree, ast::ExternCrateItem> {
|
||||
let src = self.definition_source(db);
|
||||
let (_, source_map) = db.raw_items_with_source_map(src.file_id);
|
||||
source_map.get(&src.value, import)
|
||||
}
|
||||
|
||||
/// Returns the crate this module is part of.
|
||||
pub fn krate(self) -> Crate {
|
||||
Crate { crate_id: self.id.krate }
|
||||
|
@ -189,11 +178,13 @@ impl Module {
|
|||
}
|
||||
|
||||
/// Returns a `ModuleScope`: a set of items, visible in this module.
|
||||
pub fn scope(self, db: &impl HirDatabase) -> Vec<(Name, ScopeDef, Option<ImportId>)> {
|
||||
pub fn scope(self, db: &impl HirDatabase) -> Vec<(Name, ScopeDef, Option<Import>)> {
|
||||
db.crate_def_map(self.id.krate)[self.id.module_id]
|
||||
.scope
|
||||
.entries()
|
||||
.map(|(name, res)| (name.clone(), res.def.into(), res.import))
|
||||
.map(|(name, res)| {
|
||||
(name.clone(), res.def.into(), res.import.map(|id| Import { parent: self, id }))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
@ -236,6 +227,11 @@ impl Module {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Import {
|
||||
pub(crate) parent: Module,
|
||||
pub(crate) id: ImportId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct StructField {
|
||||
pub(crate) parent: VariantDef,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue