aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-13 07:31:03 +0100
committerAleksey Kladov <[email protected]>2019-04-13 07:31:03 +0100
commit3aae223d938e5a36d997c45a0f86cfcabf83b570 (patch)
tree354c1e3c3a5e07b233c4e8490225f9be720a3315 /crates/ra_hir/src/source_binder.rs
parent58fe5598e70eef6edf109865cb87b806b22536fb (diff)
hide some scopes
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 0d2746ac0..bdb300311 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -17,6 +17,7 @@ use ra_syntax::{
17use crate::{ 17use crate::{
18 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, 18 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody,
19 AsName, Module, HirFileId, Crate, Trait, Resolver, 19 AsName, Module, HirFileId, Crate, Trait, Resolver,
20 expr::scope::{ReferenceDescriptor, ScopeEntryWithSyntax},
20 ids::LocationCtx, 21 ids::LocationCtx,
21 expr, AstId 22 expr, AstId
22}; 23};
@@ -222,6 +223,7 @@ pub struct SourceAnalyzer {
222 resolver: Resolver, 223 resolver: Resolver,
223 body_source_map: Option<Arc<crate::expr::BodySourceMap>>, 224 body_source_map: Option<Arc<crate::expr::BodySourceMap>>,
224 infer: Option<Arc<crate::ty::InferenceResult>>, 225 infer: Option<Arc<crate::ty::InferenceResult>>,
226 scopes: Option<crate::expr::ScopesWithSourceMap>,
225} 227}
226 228
227#[derive(Debug, Clone, PartialEq, Eq)] 229#[derive(Debug, Clone, PartialEq, Eq)]
@@ -248,6 +250,7 @@ impl SourceAnalyzer {
248 resolver: resolver_for_node(db, file_id, node, offset), 250 resolver: resolver_for_node(db, file_id, node, offset),
249 body_source_map: def_with_body.map(|it| it.body_source_map(db)), 251 body_source_map: def_with_body.map(|it| it.body_source_map(db)),
250 infer: def_with_body.map(|it| it.infer(db)), 252 infer: def_with_body.map(|it| it.infer(db)),
253 scopes: def_with_body.map(|it| it.scopes(db)),
251 } 254 }
252 } 255 }
253 256
@@ -302,6 +305,14 @@ impl SourceAnalyzer {
302 Some(res) 305 Some(res)
303 } 306 }
304 307
308 pub fn find_all_refs(&self, pat: &ast::BindPat) -> Option<Vec<ReferenceDescriptor>> {
309 self.scopes.as_ref().map(|it| it.find_all_refs(pat))
310 }
311
312 pub fn resolve_local_name(&self, name_ref: &ast::NameRef) -> Option<ScopeEntryWithSyntax> {
313 self.scopes.as_ref()?.resolve_local_name(name_ref)
314 }
315
305 #[cfg(test)] 316 #[cfg(test)]
306 pub(crate) fn body_source_map(&self) -> Arc<crate::expr::BodySourceMap> { 317 pub(crate) fn body_source_map(&self) -> Arc<crate::expr::BodySourceMap> {
307 self.body_source_map.clone().unwrap() 318 self.body_source_map.clone().unwrap()