From 5d72b96988587699e0a1c62c08bd76d2a7fed100 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 24 Feb 2019 17:25:41 +0100 Subject: Implement support for type aliases --- crates/ra_hir/src/code_model_api.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 0779a08a9..29c08e34b 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -626,6 +626,23 @@ impl Type { let module_impls = db.impls_in_module(self.module(db)); ImplBlock::containing(module_impls, (*self).into()) } + + pub fn type_ref(self, db: &impl PersistentHirDatabase) -> Arc { + db.type_alias_ref(self) + } + + /// Builds a resolver for the type references in this type alias. + pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { + // take the outer scope... + let r = self + .impl_block(db) + .map(|ib| ib.resolver(db)) + .unwrap_or_else(|| self.module(db).resolver(db)); + // ...and add generic params, if present + let p = self.generic_params(db); + let r = if !p.params.is_empty() { r.push_generic_params_scope(p) } else { r }; + r + } } impl Docs for Type { -- cgit v1.2.3