diff options
author | Aleksey Kladov <[email protected]> | 2019-01-24 15:56:38 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-24 15:56:38 +0000 |
commit | 566c8e321e89e5ff8996daa615cc47aea0012881 (patch) | |
tree | 58c2f4741b9305e840d41eb35eb8f4e7d5761fe2 /crates/ra_hir/src/code_model_impl | |
parent | cefc5cbb4a95d2a473ea656efe603bef979b5c49 (diff) |
migrate enums to new id
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 42 |
1 files changed, 18 insertions, 24 deletions
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}; | |||
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | Module, ModuleSource, Problem, ModuleDef, | 5 | Module, ModuleSource, Problem, ModuleDef, |
6 | Crate, Name, Path, PathKind, PerNs, Def, | 6 | Crate, Name, Path, PathKind, PerNs, |
7 | module_tree::ModuleId, | 7 | module_tree::ModuleId, |
8 | nameres::{ModuleScope, lower::ImportId}, | 8 | nameres::{ModuleScope, lower::ImportId}, |
9 | db::HirDatabase, | 9 | db::HirDatabase, |
@@ -135,31 +135,25 @@ impl Module { | |||
135 | None => PerNs::none(), | 135 | None => PerNs::none(), |
136 | } | 136 | } |
137 | } | 137 | } |
138 | ModuleDef::Function(_) | ModuleDef::Struct(_) => PerNs::none(), | 138 | ModuleDef::Enum(e) => { |
139 | ModuleDef::Def(def) => { | 139 | // enum variant |
140 | match def.resolve(db) { | 140 | let matching_variant = e |
141 | Def::Enum(e) => { | 141 | .variants(db) |
142 | // enum variant | 142 | .into_iter() |
143 | let matching_variant = e | 143 | .find(|(n, _variant)| n == &segment.name); |
144 | .variants(db) | 144 | |
145 | .into_iter() | 145 | match matching_variant { |
146 | .find(|(n, _variant)| n == &segment.name); | 146 | Some((_n, variant)) => PerNs::both(variant.def_id().into(), (*e).into()), |
147 | 147 | None => PerNs::none(), | |
148 | match matching_variant { | ||
149 | Some((_n, variant)) => { | ||
150 | PerNs::both(variant.def_id().into(), e.def_id().into()) | ||
151 | } | ||
152 | None => PerNs::none(), | ||
153 | } | ||
154 | } | ||
155 | _ => { | ||
156 | // could be an inherent method call in UFCS form | ||
157 | // (`Struct::method`), or some other kind of associated | ||
158 | // item... Which we currently don't handle (TODO) | ||
159 | PerNs::none() | ||
160 | } | ||
161 | } | 148 | } |
162 | } | 149 | } |
150 | ModuleDef::Function(_) | ModuleDef::Struct(_) => { | ||
151 | // could be an inherent method call in UFCS form | ||
152 | // (`Struct::method`), or some other kind of associated | ||
153 | // item... Which we currently don't handle (TODO) | ||
154 | PerNs::none() | ||
155 | } | ||
156 | ModuleDef::Def(_) => PerNs::none(), | ||
163 | }; | 157 | }; |
164 | } | 158 | } |
165 | curr_per_ns | 159 | curr_per_ns |