diff options
author | Aleksey Kladov <[email protected]> | 2019-11-21 09:21:46 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-21 10:25:03 +0000 |
commit | 0102fb41337ac0442e689d410bb424d215e9a7bd (patch) | |
tree | c77bf501427adc77c0fc92fe75fd9f314087b120 /crates/ra_hir/src/source_binder.rs | |
parent | 612a72fc4ea4376920f2a7da7b3c334227c1716c (diff) |
Decouple Resolver
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 727310f06..5abb8d693 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -25,8 +25,9 @@ use crate::{ | |||
25 | ids::LocationCtx, | 25 | ids::LocationCtx, |
26 | resolve::{HasResolver, ScopeDef, TypeNs, ValueNs}, | 26 | resolve::{HasResolver, ScopeDef, TypeNs, ValueNs}, |
27 | ty::method_resolution::{self, implements_trait}, | 27 | ty::method_resolution::{self, implements_trait}, |
28 | AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody, | 28 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, |
29 | HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, | 29 | GenericParam, HasBody, HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, |
30 | Struct, Trait, Ty, TypeAlias, | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { | 33 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { |
@@ -240,16 +241,18 @@ impl SourceAnalyzer { | |||
240 | path: &crate::Path, | 241 | path: &crate::Path, |
241 | ) -> Option<PathResolution> { | 242 | ) -> Option<PathResolution> { |
242 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { | 243 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { |
243 | TypeNs::SelfType(it) => PathResolution::SelfType(it), | 244 | TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), |
244 | TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam { | 245 | TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam { |
245 | parent: self.resolver.generic_def().unwrap(), | 246 | parent: self.resolver.generic_def().unwrap().into(), |
246 | idx, | 247 | idx, |
247 | }), | 248 | }), |
248 | TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()), | 249 | TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { |
249 | TypeNs::EnumVariant(it) => PathResolution::Def(it.into()), | 250 | PathResolution::Def(Adt::from(it).into()) |
250 | TypeNs::TypeAlias(it) => PathResolution::Def(it.into()), | 251 | } |
252 | TypeNs::EnumVariantId(it) => PathResolution::Def(EnumVariant::from(it).into()), | ||
253 | TypeNs::TypeAliasId(it) => PathResolution::Def(TypeAlias::from(it).into()), | ||
251 | TypeNs::BuiltinType(it) => PathResolution::Def(it.into()), | 254 | TypeNs::BuiltinType(it) => PathResolution::Def(it.into()), |
252 | TypeNs::Trait(it) => PathResolution::Def(it.into()), | 255 | TypeNs::TraitId(it) => PathResolution::Def(Trait::from(it).into()), |
253 | }); | 256 | }); |
254 | let values = self.resolver.resolve_path_in_value_ns_fully(db, &path).and_then(|val| { | 257 | let values = self.resolver.resolve_path_in_value_ns_fully(db, &path).and_then(|val| { |
255 | let res = match val { | 258 | let res = match val { |
@@ -392,7 +395,7 @@ impl SourceAnalyzer { | |||
392 | let std_future_path = known::std_future_future(); | 395 | let std_future_path = known::std_future_future(); |
393 | 396 | ||
394 | let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) { | 397 | let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) { |
395 | Some(it) => it, | 398 | Some(it) => it.into(), |
396 | _ => return false, | 399 | _ => return false, |
397 | }; | 400 | }; |
398 | 401 | ||