diff options
author | Aleksey Kladov <[email protected]> | 2019-11-21 12:13:46 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-21 12:13:46 +0000 |
commit | eb53aa37a336b6c9369ea931812f6c491e8f4a71 (patch) | |
tree | 30d6f3818af29182f2dc69d4add2ad27a6538514 /crates/ra_hir/src/source_binder.rs | |
parent | ca1af86e7bb104533f9878f84a7a3a39e5107c30 (diff) |
Split internal and user-visible ScopeDef
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 467e46d8c..f13d43740 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -23,7 +23,7 @@ use crate::{ | |||
23 | db::HirDatabase, | 23 | db::HirDatabase, |
24 | expr::{BodySourceMap, ExprScopes, ScopeId}, | 24 | expr::{BodySourceMap, ExprScopes, ScopeId}, |
25 | ids::LocationCtx, | 25 | ids::LocationCtx, |
26 | resolve::{resolver_for_scope, HasResolver, TypeNs, ValueNs}, | 26 | resolve::{self, resolver_for_scope, HasResolver, TypeNs, ValueNs}, |
27 | ty::method_resolution::{self, implements_trait}, | 27 | ty::method_resolution::{self, implements_trait}, |
28 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, | 28 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, |
29 | GenericParam, HasBody, HirFileId, Local, MacroDef, Module, Name, Path, Resolver, ScopeDef, | 29 | GenericParam, HasBody, HirFileId, Local, MacroDef, Module, Name, Path, Resolver, ScopeDef, |
@@ -310,7 +310,22 @@ impl SourceAnalyzer { | |||
310 | } | 310 | } |
311 | 311 | ||
312 | pub fn process_all_names(&self, db: &impl HirDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { | 312 | pub fn process_all_names(&self, db: &impl HirDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { |
313 | self.resolver.process_all_names(db, f) | 313 | self.resolver.process_all_names(db, &mut |name, def| { |
314 | let def = match def { | ||
315 | resolve::ScopeDef::PerNs(it) => it.into(), | ||
316 | resolve::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), | ||
317 | resolve::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), | ||
318 | resolve::ScopeDef::GenericParam(idx) => { | ||
319 | let parent = self.resolver.generic_def().unwrap().into(); | ||
320 | ScopeDef::GenericParam(GenericParam { parent, idx }) | ||
321 | } | ||
322 | resolve::ScopeDef::Local(pat_id) => { | ||
323 | let parent = self.resolver.body_owner().unwrap().into(); | ||
324 | ScopeDef::Local(Local { parent, pat_id }) | ||
325 | } | ||
326 | }; | ||
327 | f(name, def) | ||
328 | }) | ||
314 | } | 329 | } |
315 | 330 | ||
316 | // FIXME: we only use this in `inline_local_variable` assist, ideally, we | 331 | // FIXME: we only use this in `inline_local_variable` assist, ideally, we |