diff options
Diffstat (limited to 'crates/ra_hir/src/lib.rs')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index a0d99a84d..7e9824de9 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -25,6 +25,7 @@ pub mod source_binder; | |||
25 | mod krate; | 25 | mod krate; |
26 | mod module; | 26 | mod module; |
27 | mod function; | 27 | mod function; |
28 | mod adt; | ||
28 | mod ty; | 29 | mod ty; |
29 | 30 | ||
30 | use std::ops::Index; | 31 | use std::ops::Index; |
@@ -42,6 +43,7 @@ pub use self::{ | |||
42 | krate::Crate, | 43 | krate::Crate, |
43 | module::{Module, ModuleId, Problem, nameres::ItemMap, ModuleScope, Resolution}, | 44 | module::{Module, ModuleId, Problem, nameres::ItemMap, ModuleScope, Resolution}, |
44 | function::{Function, FnScopes}, | 45 | function::{Function, FnScopes}, |
46 | adt::{Struct, Enum}, | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | pub use self::function::FnSignatureInfo; | 49 | pub use self::function::FnSignatureInfo; |
@@ -56,6 +58,8 @@ ra_db::impl_numeric_id!(DefId); | |||
56 | pub(crate) enum DefKind { | 58 | pub(crate) enum DefKind { |
57 | Module, | 59 | Module, |
58 | Function, | 60 | Function, |
61 | Struct, | ||
62 | Enum, | ||
59 | Item, | 63 | Item, |
60 | } | 64 | } |
61 | 65 | ||
@@ -73,8 +77,8 @@ impl DefKind { | |||
73 | SyntaxKind::FN_DEF => Some(DefKind::Function), | 77 | SyntaxKind::FN_DEF => Some(DefKind::Function), |
74 | SyntaxKind::MODULE => Some(DefKind::Module), | 78 | SyntaxKind::MODULE => Some(DefKind::Module), |
75 | // These define items, but don't have their own DefKinds yet: | 79 | // These define items, but don't have their own DefKinds yet: |
76 | SyntaxKind::STRUCT_DEF => Some(DefKind::Item), | 80 | SyntaxKind::STRUCT_DEF => Some(DefKind::Struct), |
77 | SyntaxKind::ENUM_DEF => Some(DefKind::Item), | 81 | SyntaxKind::ENUM_DEF => Some(DefKind::Enum), |
78 | SyntaxKind::TRAIT_DEF => Some(DefKind::Item), | 82 | SyntaxKind::TRAIT_DEF => Some(DefKind::Item), |
79 | SyntaxKind::TYPE_DEF => Some(DefKind::Item), | 83 | SyntaxKind::TYPE_DEF => Some(DefKind::Item), |
80 | SyntaxKind::CONST_DEF => Some(DefKind::Item), | 84 | SyntaxKind::CONST_DEF => Some(DefKind::Item), |
@@ -99,6 +103,8 @@ impl DefLoc { | |||
99 | pub enum Def { | 103 | pub enum Def { |
100 | Module(Module), | 104 | Module(Module), |
101 | Function(Function), | 105 | Function(Function), |
106 | Struct(Struct), | ||
107 | Enum(Enum), | ||
102 | Item, | 108 | Item, |
103 | } | 109 | } |
104 | 110 | ||
@@ -114,6 +120,14 @@ impl DefId { | |||
114 | let function = Function::new(self); | 120 | let function = Function::new(self); |
115 | Def::Function(function) | 121 | Def::Function(function) |
116 | } | 122 | } |
123 | DefKind::Struct => { | ||
124 | let struct_def = Struct::new(self); | ||
125 | Def::Struct(struct_def) | ||
126 | } | ||
127 | DefKind::Enum => { | ||
128 | let enum_def = Enum::new(self); | ||
129 | Def::Enum(enum_def) | ||
130 | } | ||
117 | DefKind::Item => Def::Item, | 131 | DefKind::Item => Def::Item, |
118 | }; | 132 | }; |
119 | Ok(res) | 133 | Ok(res) |