From 3c17643b3085682a695f0e6d80483edc00d04cb3 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Mon, 28 Jan 2019 09:26:32 -0500 Subject: Go to Implementation for structs and enums --- crates/ra_hir/src/code_model_api.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (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 e4008058c..691cd5798 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -10,12 +10,13 @@ use crate::{ nameres::{ModuleScope, lower::ImportId}, db::HirDatabase, expr::BodySyntaxMapping, - ty::InferenceResult, + ty::{InferenceResult}, adt::{EnumVariantId, StructFieldId, VariantDef}, generics::GenericParams, docs::{Documentation, Docs, docs_from_ast}, module_tree::ModuleId, ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId}, + impl_block::ImplId, }; /// hir::Crate describes a single crate. It's the main interface with which @@ -23,7 +24,7 @@ use crate::{ /// root module. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Crate { - pub(crate) crate_id: CrateId, + pub crate_id: CrateId, } #[derive(Debug)] @@ -126,6 +127,11 @@ impl Module { self.import_source_impl(db, import) } + /// Returns the syntax of the impl block in this module + pub fn impl_source(&self, db: &impl HirDatabase, impl_id: ImplId) -> TreeArc { + self.impl_source_impl(db, impl_id) + } + /// Returns the crate this module is part of. pub fn krate(&self, db: &impl HirDatabase) -> Option { self.krate_impl(db) @@ -272,6 +278,10 @@ impl Struct { pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { db.generic_params((*self).into()) } + + pub fn ty(&self, db: &impl HirDatabase) -> Ty { + db.type_for_def((*self).into()) + } } impl Docs for Struct { @@ -317,6 +327,10 @@ impl Enum { pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { db.generic_params((*self).into()) } + + pub fn ty(&self, db: &impl HirDatabase) -> Ty { + db.type_for_def((*self).into()) + } } impl Docs for Enum { -- cgit v1.2.3