diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 20 |
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". |
8 | use std::sync::Arc; | 8 | use std::sync::Arc; |
9 | 9 | ||
10 | use rustc_hash::FxHashSet; | 10 | use rustc_hash::{FxHashSet, FxHashMap}; |
11 | use ra_db::{FileId, FilePosition}; | 11 | use ra_db::{FileId, FilePosition}; |
12 | use ra_syntax::{ | 12 | use ra_syntax::{ |
13 | SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, | 13 | SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, |
@@ -17,7 +17,7 @@ use ra_syntax::{ | |||
17 | }; | 17 | }; |
18 | 18 | ||
19 | use crate::{ | 19 | use 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())?; |