aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/resolve.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r--crates/ra_hir/src/resolve.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 2609585b1..685f4b8b1 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -9,13 +9,13 @@ use crate::{
9 name::{Name, KnownName}, 9 name::{Name, KnownName},
10 nameres::{PerNs, CrateDefMap, CrateModuleId}, 10 nameres::{PerNs, CrateDefMap, CrateModuleId},
11 generics::GenericParams, 11 generics::GenericParams,
12 expr::{scope::{ExprScopes, ScopeId}, PatId, Body}, 12 expr::{scope::{ExprScopes, ScopeId}, PatId},
13 impl_block::ImplBlock, 13 impl_block::ImplBlock,
14 path::Path, Trait 14 path::Path, Trait
15}; 15};
16 16
17#[derive(Debug, Clone, Default)] 17#[derive(Debug, Clone, Default)]
18pub struct Resolver { 18pub(crate) struct Resolver {
19 scopes: Vec<Scope>, 19 scopes: Vec<Scope>,
20} 20}
21 21
@@ -117,7 +117,7 @@ pub enum Resolution {
117} 117}
118 118
119impl Resolver { 119impl Resolver {
120 pub fn resolve_name(&self, db: &impl HirDatabase, name: &Name) -> PerNs<Resolution> { 120 pub(crate) fn resolve_name(&self, db: &impl HirDatabase, name: &Name) -> PerNs<Resolution> {
121 let mut resolution = PerNs::none(); 121 let mut resolution = PerNs::none();
122 for scope in self.scopes.iter().rev() { 122 for scope in self.scopes.iter().rev() {
123 resolution = resolution.or(scope.resolve_name(db, name)); 123 resolution = resolution.or(scope.resolve_name(db, name));
@@ -154,12 +154,12 @@ impl Resolver {
154 154
155 /// Returns the fully resolved path if we were able to resolve it. 155 /// Returns the fully resolved path if we were able to resolve it.
156 /// otherwise returns `PerNs::none` 156 /// otherwise returns `PerNs::none`
157 pub fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> PerNs<Resolution> { 157 pub(crate) fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> PerNs<Resolution> {
158 // into_fully_resolved() returns the fully resolved path or PerNs::none() otherwise 158 // into_fully_resolved() returns the fully resolved path or PerNs::none() otherwise
159 self.resolve_path_segments(db, path).into_fully_resolved() 159 self.resolve_path_segments(db, path).into_fully_resolved()
160 } 160 }
161 161
162 pub fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<Resolution>> { 162 pub(crate) fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<Resolution>> {
163 let mut names = FxHashMap::default(); 163 let mut names = FxHashMap::default();
164 for scope in self.scopes.iter().rev() { 164 for scope in self.scopes.iter().rev() {
165 scope.collect_names(db, &mut |name, res| { 165 scope.collect_names(db, &mut |name, res| {
@@ -197,14 +197,6 @@ impl Resolver {
197 _ => None, 197 _ => None,
198 }) 198 })
199 } 199 }
200
201 /// The body from which any `LocalBinding` resolutions in this resolver come.
202 pub fn body(&self) -> Option<Arc<Body>> {
203 self.scopes.iter().rev().find_map(|scope| match scope {
204 Scope::ExprScope(expr_scope) => Some(expr_scope.expr_scopes.body()),
205 _ => None,
206 })
207 }
208} 200}
209 201
210impl Resolver { 202impl Resolver {