From 566c8e321e89e5ff8996daa615cc47aea0012881 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 18:56:38 +0300 Subject: migrate enums to new id --- crates/ra_hir/src/code_model_impl/module.rs | 42 +++++++++++++---------------- 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'crates/ra_hir/src/code_model_impl') diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 42f10e941..4ea649770 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -3,7 +3,7 @@ use ra_syntax::{ast, SyntaxNode, TreeArc}; use crate::{ Module, ModuleSource, Problem, ModuleDef, - Crate, Name, Path, PathKind, PerNs, Def, + Crate, Name, Path, PathKind, PerNs, module_tree::ModuleId, nameres::{ModuleScope, lower::ImportId}, db::HirDatabase, @@ -135,31 +135,25 @@ impl Module { None => PerNs::none(), } } - ModuleDef::Function(_) | ModuleDef::Struct(_) => PerNs::none(), - ModuleDef::Def(def) => { - match def.resolve(db) { - Def::Enum(e) => { - // enum variant - let matching_variant = e - .variants(db) - .into_iter() - .find(|(n, _variant)| n == &segment.name); - - match matching_variant { - Some((_n, variant)) => { - PerNs::both(variant.def_id().into(), e.def_id().into()) - } - None => PerNs::none(), - } - } - _ => { - // could be an inherent method call in UFCS form - // (`Struct::method`), or some other kind of associated - // item... Which we currently don't handle (TODO) - PerNs::none() - } + ModuleDef::Enum(e) => { + // enum variant + let matching_variant = e + .variants(db) + .into_iter() + .find(|(n, _variant)| n == &segment.name); + + match matching_variant { + Some((_n, variant)) => PerNs::both(variant.def_id().into(), (*e).into()), + None => PerNs::none(), } } + ModuleDef::Function(_) | ModuleDef::Struct(_) => { + // could be an inherent method call in UFCS form + // (`Struct::method`), or some other kind of associated + // item... Which we currently don't handle (TODO) + PerNs::none() + } + ModuleDef::Def(_) => PerNs::none(), }; } curr_per_ns -- cgit v1.2.3