diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index e86077dd6..5766cc3b8 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -186,21 +186,34 @@ impl ModuleDef { | |||
186 | module.visibility_of(db, self) | 186 | module.visibility_of(db, self) |
187 | } | 187 | } |
188 | 188 | ||
189 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { | 189 | pub fn name(&self, db: &dyn HirDatabase) -> Option<Name> { |
190 | match self { | 190 | match self { |
191 | ModuleDef::Adt(it) => Some(it.name(db)), | 191 | ModuleDef::Module(m) => m.name(db), |
192 | ModuleDef::Trait(it) => Some(it.name(db)), | 192 | ModuleDef::Function(m) => Some(m.name(db)), |
193 | ModuleDef::Function(it) => Some(it.name(db)), | 193 | ModuleDef::Adt(m) => Some(m.name(db)), |
194 | ModuleDef::EnumVariant(it) => Some(it.name(db)), | 194 | ModuleDef::EnumVariant(m) => Some(m.name(db)), |
195 | ModuleDef::TypeAlias(it) => Some(it.name(db)), | 195 | ModuleDef::Const(m) => {m.name(db)}, |
196 | 196 | ModuleDef::Static(m) => {m.name(db)}, | |
197 | ModuleDef::Module(it) => it.name(db), | 197 | ModuleDef::Trait(m) => {Some(m.name(db))}, |
198 | ModuleDef::Const(it) => it.name(db), | 198 | ModuleDef::TypeAlias(m) => {Some(m.name(db))}, |
199 | ModuleDef::Static(it) => it.name(db), | 199 | ModuleDef::BuiltinType(m) => {Some(m.as_name())} |
200 | |||
201 | ModuleDef::BuiltinType(it) => Some(it.as_name()), | ||
202 | } | 200 | } |
203 | } | 201 | } |
202 | |||
203 | pub fn resolver<D: DefDatabase + HirDatabase>(&self, db: &D) -> Option<Resolver> { | ||
204 | Some(match self { | ||
205 | ModuleDef::Module(m) => Into::<ModuleId>::into(m.clone()).resolver(db), | ||
206 | ModuleDef::Function(f) => Into::<FunctionId>::into(f.clone()).resolver(db), | ||
207 | ModuleDef::Adt(adt) => Into::<AdtId>::into(adt.clone()).resolver(db), | ||
208 | ModuleDef::EnumVariant(ev) => Into::<GenericDefId>::into(Into::<GenericDef>::into(ev.clone())).resolver(db), | ||
209 | ModuleDef::Const(c) => Into::<GenericDefId>::into(Into::<GenericDef>::into(c.clone())).resolver(db), | ||
210 | ModuleDef::Static(s) => Into::<StaticId>::into(s.clone()).resolver(db), | ||
211 | ModuleDef::Trait(t) => Into::<TraitId>::into(t.clone()).resolver(db), | ||
212 | ModuleDef::TypeAlias(t) => Into::<ModuleId>::into(t.module(db)).resolver(db), | ||
213 | // TODO: This should be a resolver relative to `std` | ||
214 | ModuleDef::BuiltinType(_t) => None? | ||
215 | }) | ||
216 | } | ||
204 | } | 217 | } |
205 | 218 | ||
206 | pub use hir_def::{ | 219 | pub use hir_def::{ |