mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
make resolver private
This commit is contained in:
parent
62d01dd4df
commit
a2cc76ce63
6 changed files with 23 additions and 26 deletions
|
@ -9,13 +9,13 @@ use crate::{
|
|||
name::{Name, KnownName},
|
||||
nameres::{PerNs, CrateDefMap, CrateModuleId},
|
||||
generics::GenericParams,
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId, Body},
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId},
|
||||
impl_block::ImplBlock,
|
||||
path::Path, Trait
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Resolver {
|
||||
pub(crate) struct Resolver {
|
||||
scopes: Vec<Scope>,
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ pub enum Resolution {
|
|||
}
|
||||
|
||||
impl Resolver {
|
||||
pub fn resolve_name(&self, db: &impl HirDatabase, name: &Name) -> PerNs<Resolution> {
|
||||
pub(crate) fn resolve_name(&self, db: &impl HirDatabase, name: &Name) -> PerNs<Resolution> {
|
||||
let mut resolution = PerNs::none();
|
||||
for scope in self.scopes.iter().rev() {
|
||||
resolution = resolution.or(scope.resolve_name(db, name));
|
||||
|
@ -154,12 +154,12 @@ impl Resolver {
|
|||
|
||||
/// Returns the fully resolved path if we were able to resolve it.
|
||||
/// otherwise returns `PerNs::none`
|
||||
pub fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> PerNs<Resolution> {
|
||||
pub(crate) fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> PerNs<Resolution> {
|
||||
// into_fully_resolved() returns the fully resolved path or PerNs::none() otherwise
|
||||
self.resolve_path_segments(db, path).into_fully_resolved()
|
||||
}
|
||||
|
||||
pub fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<Resolution>> {
|
||||
pub(crate) fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<Resolution>> {
|
||||
let mut names = FxHashMap::default();
|
||||
for scope in self.scopes.iter().rev() {
|
||||
scope.collect_names(db, &mut |name, res| {
|
||||
|
@ -197,14 +197,6 @@ impl Resolver {
|
|||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The body from which any `LocalBinding` resolutions in this resolver come.
|
||||
pub fn body(&self) -> Option<Arc<Body>> {
|
||||
self.scopes.iter().rev().find_map(|scope| match scope {
|
||||
Scope::ExprScope(expr_scope) => Some(expr_scope.expr_scopes.body()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Resolver {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue