aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-13 09:00:15 +0100
committerAleksey Kladov <[email protected]>2019-04-13 09:00:15 +0100
commit62d01dd4dfc8feb52c006b84f9d1a1a7142cc060 (patch)
tree82c6e8b1b51f5a0de63e038fd6d872cd39882015 /crates/ra_hir
parentf4a94e74bcd6c8f9275a57a775e64314af1878da (diff)
hide resolver
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/source_binder.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index d87f8ff34..b5e2f86be 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -7,7 +7,7 @@
7/// purely for "IDE needs". 7/// purely for "IDE needs".
8use std::sync::Arc; 8use std::sync::Arc;
9 9
10use rustc_hash::FxHashSet; 10use rustc_hash::{FxHashSet, FxHashMap};
11use ra_db::{FileId, FilePosition}; 11use ra_db::{FileId, FilePosition};
12use ra_syntax::{ 12use ra_syntax::{
13 SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, 13 SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr,
@@ -17,7 +17,7 @@ use ra_syntax::{
17}; 17};
18 18
19use crate::{ 19use crate::{
20 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, 20 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
21 AsName, Module, HirFileId, Crate, Trait, Resolver, 21 AsName, Module, HirFileId, Crate, Trait, Resolver,
22 expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeEntryWithSyntax, ScopeId, ExprScopes}}, 22 expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeEntryWithSyntax, ScopeId, ExprScopes}},
23 ids::LocationCtx, 23 ids::LocationCtx,
@@ -222,10 +222,6 @@ impl SourceAnalyzer {
222 } 222 }
223 } 223 }
224 224
225 pub fn resolver(&self) -> &Resolver {
226 &self.resolver
227 }
228
229 pub fn type_of(&self, _db: &impl HirDatabase, expr: &ast::Expr) -> Option<crate::Ty> { 225 pub fn type_of(&self, _db: &impl HirDatabase, expr: &ast::Expr) -> Option<crate::Ty> {
230 let expr_id = self.body_source_map.as_ref()?.node_expr(expr)?; 226 let expr_id = self.body_source_map.as_ref()?.node_expr(expr)?;
231 Some(self.infer.as_ref()?[expr_id].clone()) 227 Some(self.infer.as_ref()?[expr_id].clone())
@@ -246,6 +242,18 @@ impl SourceAnalyzer {
246 self.infer.as_ref()?.field_resolution(expr_id) 242 self.infer.as_ref()?.field_resolution(expr_id)
247 } 243 }
248 244
245 pub fn resolve_hir_path(
246 &self,
247 db: &impl HirDatabase,
248 path: &crate::Path,
249 ) -> PerNs<crate::Resolution> {
250 self.resolver.resolve_path(db, path)
251 }
252
253 pub fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<crate::Resolution>> {
254 self.resolver.all_names(db)
255 }
256
249 pub fn resolve_path(&self, db: &impl HirDatabase, path: &ast::Path) -> Option<PathResolution> { 257 pub fn resolve_path(&self, db: &impl HirDatabase, path: &ast::Path) -> Option<PathResolution> {
250 if let Some(path_expr) = path.syntax().parent().and_then(ast::PathExpr::cast) { 258 if let Some(path_expr) = path.syntax().parent().and_then(ast::PathExpr::cast) {
251 let expr_id = self.body_source_map.as_ref()?.node_expr(path_expr.into())?; 259 let expr_id = self.body_source_map.as_ref()?.node_expr(path_expr.into())?;