diff options
author | Aleksey Kladov <[email protected]> | 2019-01-11 18:02:12 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-11 18:02:12 +0000 |
commit | f193fbcbae0783953cfaa88aaec6a8d4e1255007 (patch) | |
tree | c57734dc82350c2d853f557a40f7aafdc7470bdf /crates/ra_hir/src/code_model_api.rs | |
parent | 19136cde000c2c227e79bf44febde990fe265cb7 (diff) |
actually produce missing def kinds
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 48 |
1 files changed, 48 insertions, 0 deletions
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 { | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | #[derive(Debug)] | ||
44 | pub enum Def { | 45 | pub enum Def { |
45 | Module(Module), | 46 | Module(Module), |
46 | Struct(Struct), | 47 | Struct(Struct), |
47 | Enum(Enum), | 48 | Enum(Enum), |
48 | EnumVariant(EnumVariant), | 49 | EnumVariant(EnumVariant), |
49 | Function(Function), | 50 | Function(Function), |
51 | Const(Const), | ||
52 | Static(Static), | ||
53 | Trait(Trait), | ||
54 | Type(Type), | ||
50 | Item, | 55 | Item, |
51 | } | 56 | } |
52 | 57 | ||
@@ -317,17 +322,60 @@ pub struct Const { | |||
317 | pub(crate) def_id: DefId, | 322 | pub(crate) def_id: DefId, |
318 | } | 323 | } |
319 | 324 | ||
325 | impl Const { | ||
326 | pub(crate) fn new(def_id: DefId) -> Const { | ||
327 | Const { def_id } | ||
328 | } | ||
329 | |||
330 | pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::ConstDef>)> { | ||
331 | Ok(def_id_to_ast(db, self.def_id)) | ||
332 | } | ||
333 | } | ||
334 | |||
320 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 335 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
321 | pub struct Static { | 336 | pub struct Static { |
322 | pub(crate) def_id: DefId, | 337 | pub(crate) def_id: DefId, |
323 | } | 338 | } |
324 | 339 | ||
340 | impl Static { | ||
341 | pub(crate) fn new(def_id: DefId) -> Static { | ||
342 | Static { def_id } | ||
343 | } | ||
344 | |||
345 | pub fn source( | ||
346 | &self, | ||
347 | db: &impl HirDatabase, | ||
348 | ) -> Cancelable<(HirFileId, TreeArc<ast::StaticDef>)> { | ||
349 | Ok(def_id_to_ast(db, self.def_id)) | ||
350 | } | ||
351 | } | ||
352 | |||
325 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 353 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
326 | pub struct Trait { | 354 | pub struct Trait { |
327 | pub(crate) def_id: DefId, | 355 | pub(crate) def_id: DefId, |
328 | } | 356 | } |
329 | 357 | ||
358 | impl Trait { | ||
359 | pub(crate) fn new(def_id: DefId) -> Trait { | ||
360 | Trait { def_id } | ||
361 | } | ||
362 | |||
363 | pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TraitDef>)> { | ||
364 | Ok(def_id_to_ast(db, self.def_id)) | ||
365 | } | ||
366 | } | ||
367 | |||
330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
331 | pub struct Type { | 369 | pub struct Type { |
332 | pub(crate) def_id: DefId, | 370 | pub(crate) def_id: DefId, |
333 | } | 371 | } |
372 | |||
373 | impl Type { | ||
374 | pub(crate) fn new(def_id: DefId) -> Type { | ||
375 | Type { def_id } | ||
376 | } | ||
377 | |||
378 | pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TypeDef>)> { | ||
379 | Ok(def_id_to_ast(db, self.def_id)) | ||
380 | } | ||
381 | } | ||