mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
actually produce missing def kinds
This commit is contained in:
parent
19136cde00
commit
f193fbcbae
7 changed files with 122 additions and 8 deletions
|
@ -41,12 +41,17 @@ impl Crate {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Def {
|
||||
Module(Module),
|
||||
Struct(Struct),
|
||||
Enum(Enum),
|
||||
EnumVariant(EnumVariant),
|
||||
Function(Function),
|
||||
Const(Const),
|
||||
Static(Static),
|
||||
Trait(Trait),
|
||||
Type(Type),
|
||||
Item,
|
||||
}
|
||||
|
||||
|
@ -317,17 +322,60 @@ pub struct Const {
|
|||
pub(crate) def_id: DefId,
|
||||
}
|
||||
|
||||
impl Const {
|
||||
pub(crate) fn new(def_id: DefId) -> Const {
|
||||
Const { def_id }
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::ConstDef>)> {
|
||||
Ok(def_id_to_ast(db, self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Static {
|
||||
pub(crate) def_id: DefId,
|
||||
}
|
||||
|
||||
impl Static {
|
||||
pub(crate) fn new(def_id: DefId) -> Static {
|
||||
Static { def_id }
|
||||
}
|
||||
|
||||
pub fn source(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<(HirFileId, TreeArc<ast::StaticDef>)> {
|
||||
Ok(def_id_to_ast(db, self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Trait {
|
||||
pub(crate) def_id: DefId,
|
||||
}
|
||||
|
||||
impl Trait {
|
||||
pub(crate) fn new(def_id: DefId) -> Trait {
|
||||
Trait { def_id }
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TraitDef>)> {
|
||||
Ok(def_id_to_ast(db, self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Type {
|
||||
pub(crate) def_id: DefId,
|
||||
}
|
||||
|
||||
impl Type {
|
||||
pub(crate) fn new(def_id: DefId) -> Type {
|
||||
Type { def_id }
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TypeDef>)> {
|
||||
Ok(def_id_to_ast(db, self.def_id))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue