diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 20 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 6 |
2 files changed, 23 insertions, 3 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 36c0bdc9e..5d88c5c64 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -196,7 +196,6 @@ impl ModuleDef { | |||
196 | ModuleDef::Function(it) => Some(it.name(db)), | 196 | ModuleDef::Function(it) => Some(it.name(db)), |
197 | ModuleDef::EnumVariant(it) => Some(it.name(db)), | 197 | ModuleDef::EnumVariant(it) => Some(it.name(db)), |
198 | ModuleDef::TypeAlias(it) => Some(it.name(db)), | 198 | ModuleDef::TypeAlias(it) => Some(it.name(db)), |
199 | |||
200 | ModuleDef::Module(it) => it.name(db), | 199 | ModuleDef::Module(it) => it.name(db), |
201 | ModuleDef::Const(it) => it.name(db), | 200 | ModuleDef::Const(it) => it.name(db), |
202 | ModuleDef::Static(it) => it.name(db), | 201 | ModuleDef::Static(it) => it.name(db), |
@@ -204,6 +203,25 @@ impl ModuleDef { | |||
204 | ModuleDef::BuiltinType(it) => Some(it.as_name()), | 203 | ModuleDef::BuiltinType(it) => Some(it.as_name()), |
205 | } | 204 | } |
206 | } | 205 | } |
206 | |||
207 | pub fn resolver<D: DefDatabase + HirDatabase>(&self, db: &D) -> Option<Resolver> { | ||
208 | Some(match self { | ||
209 | ModuleDef::Module(m) => ModuleId::from(m.clone()).resolver(db), | ||
210 | ModuleDef::Function(f) => FunctionId::from(f.clone()).resolver(db), | ||
211 | ModuleDef::Adt(adt) => AdtId::from(adt.clone()).resolver(db), | ||
212 | ModuleDef::EnumVariant(ev) => { | ||
213 | GenericDefId::from(GenericDef::from(ev.clone())).resolver(db) | ||
214 | } | ||
215 | ModuleDef::Const(c) => { | ||
216 | GenericDefId::from(GenericDef::from(c.clone())).resolver(db) | ||
217 | } | ||
218 | ModuleDef::Static(s) => StaticId::from(s.clone()).resolver(db), | ||
219 | ModuleDef::Trait(t) => TraitId::from(t.clone()).resolver(db), | ||
220 | ModuleDef::TypeAlias(t) => ModuleId::from(t.module(db)).resolver(db), | ||
221 | // FIXME: This should be a resolver relative to `std/core` | ||
222 | ModuleDef::BuiltinType(_t) => None?, | ||
223 | }) | ||
224 | } | ||
207 | } | 225 | } |
208 | 226 | ||
209 | pub use hir_def::{ | 227 | pub use hir_def::{ |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 31f3241c9..e2d13dbfd 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -47,13 +47,15 @@ pub use hir_def::{ | |||
47 | body::scope::ExprScopes, | 47 | body::scope::ExprScopes, |
48 | builtin_type::BuiltinType, | 48 | builtin_type::BuiltinType, |
49 | docs::Documentation, | 49 | docs::Documentation, |
50 | item_scope::ItemInNs, | ||
50 | nameres::ModuleSource, | 51 | nameres::ModuleSource, |
51 | path::{ModPath, Path, PathKind}, | 52 | path::{ModPath, Path, PathKind}, |
52 | type_ref::Mutability, | 53 | type_ref::Mutability, |
53 | }; | 54 | }; |
54 | pub use hir_expand::{ | 55 | pub use hir_expand::{ |
55 | hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, | 56 | hygiene::Hygiene, |
56 | MacroDefId, /* FIXME */ | 57 | name::{AsName, Name}, |
58 | HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, /* FIXME */ | ||
57 | MacroFile, Origin, | 59 | MacroFile, Origin, |
58 | }; | 60 | }; |
59 | pub use hir_ty::display::HirDisplay; | 61 | pub use hir_ty::display::HirDisplay; |