diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index e4008058c..53e84429c 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::{ | |||
10 | nameres::{ModuleScope, lower::ImportId}, | 10 | nameres::{ModuleScope, lower::ImportId}, |
11 | db::HirDatabase, | 11 | db::HirDatabase, |
12 | expr::BodySyntaxMapping, | 12 | expr::BodySyntaxMapping, |
13 | ty::InferenceResult, | 13 | ty::{InferenceResult}, |
14 | adt::{EnumVariantId, StructFieldId, VariantDef}, | 14 | adt::{EnumVariantId, StructFieldId, VariantDef}, |
15 | generics::GenericParams, | 15 | generics::GenericParams, |
16 | docs::{Documentation, Docs, docs_from_ast}, | 16 | docs::{Documentation, Docs, docs_from_ast}, |
17 | module_tree::ModuleId, | 17 | module_tree::ModuleId, |
18 | ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId}, | 18 | ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId}, |
19 | impl_block::ImplId, | ||
19 | }; | 20 | }; |
20 | 21 | ||
21 | /// hir::Crate describes a single crate. It's the main interface with which | 22 | /// hir::Crate describes a single crate. It's the main interface with which |
@@ -126,6 +127,11 @@ impl Module { | |||
126 | self.import_source_impl(db, import) | 127 | self.import_source_impl(db, import) |
127 | } | 128 | } |
128 | 129 | ||
130 | /// Returns the syntax of the impl block in this module | ||
131 | pub fn impl_source(&self, db: &impl HirDatabase, impl_id: ImplId) -> TreeArc<ast::ImplBlock> { | ||
132 | self.impl_source_impl(db, impl_id) | ||
133 | } | ||
134 | |||
129 | /// Returns the crate this module is part of. | 135 | /// Returns the crate this module is part of. |
130 | pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> { | 136 | pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> { |
131 | self.krate_impl(db) | 137 | self.krate_impl(db) |
@@ -272,6 +278,10 @@ impl Struct { | |||
272 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { | 278 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { |
273 | db.generic_params((*self).into()) | 279 | db.generic_params((*self).into()) |
274 | } | 280 | } |
281 | |||
282 | pub fn ty(&self, db: &impl HirDatabase) -> Ty { | ||
283 | db.type_for_def((*self).into()) | ||
284 | } | ||
275 | } | 285 | } |
276 | 286 | ||
277 | impl Docs for Struct { | 287 | impl Docs for Struct { |
@@ -317,6 +327,10 @@ impl Enum { | |||
317 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { | 327 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { |
318 | db.generic_params((*self).into()) | 328 | db.generic_params((*self).into()) |
319 | } | 329 | } |
330 | |||
331 | pub fn ty(&self, db: &impl HirDatabase) -> Ty { | ||
332 | db.type_for_def((*self).into()) | ||
333 | } | ||
320 | } | 334 | } |
321 | 335 | ||
322 | impl Docs for Enum { | 336 | impl Docs for Enum { |