From f193fbcbae0783953cfaa88aaec6a8d4e1255007 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 11 Jan 2019 21:02:12 +0300 Subject: actually produce missing def kinds --- crates/ra_hir/src/code_model_api.rs | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 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 5f61bb589..d4244f70c 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -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)> { + 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)> { + 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)> { + 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)> { + Ok(def_id_to_ast(db, self.def_id)) + } +} -- cgit v1.2.3