mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Go to Implementation for structs and enums
This commit is contained in:
parent
48d2acb297
commit
3c17643b30
14 changed files with 279 additions and 18 deletions
|
@ -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<ast::ImplBlock> {
|
||||
self.impl_source_impl(db, impl_id)
|
||||
}
|
||||
|
||||
/// Returns the crate this module is part of.
|
||||
pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> {
|
||||
self.krate_impl(db)
|
||||
|
@ -272,6 +278,10 @@ impl Struct {
|
|||
pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
|
||||
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<GenericParams> {
|
||||
db.generic_params((*self).into())
|
||||
}
|
||||
|
||||
pub fn ty(&self, db: &impl HirDatabase) -> Ty {
|
||||
db.type_for_def((*self).into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Docs for Enum {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue