aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs32
1 files changed, 26 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 0805fd3db..316896dce 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -4,11 +4,10 @@ use ra_arena::{Arena, RawId, impl_arena_id};
4 4
5use crate::{ 5use crate::{
6 HirDatabase, PerNs, Def, Function, Struct, Enum, EnumVariant, ImplBlock, Crate, 6 HirDatabase, PerNs, Def, Function, Struct, Enum, EnumVariant, ImplBlock, Crate,
7 Module, Trait, Type, Static, Const,
7 module_tree::ModuleId, 8 module_tree::ModuleId,
8}; 9};
9 10
10use crate::code_model_api::Module;
11
12/// hir makes heavy use of ids: integer (u32) handlers to various things. You 11/// hir makes heavy use of ids: integer (u32) handlers to various things. You
13/// can think of id as a pointer (but without a lifetime) or a file descriptor 12/// can think of id as a pointer (but without a lifetime) or a file descriptor
14/// (but for hir objects). 13/// (but for hir objects).
@@ -146,6 +145,10 @@ pub(crate) enum DefKind {
146 Struct, 145 Struct,
147 Enum, 146 Enum,
148 EnumVariant, 147 EnumVariant,
148 Const,
149 Static,
150 Trait,
151 Type,
149 Item, 152 Item,
150 153
151 StructCtor, 154 StructCtor,
@@ -173,6 +176,23 @@ impl DefId {
173 } 176 }
174 DefKind::Enum => Def::Enum(Enum::new(self)), 177 DefKind::Enum => Def::Enum(Enum::new(self)),
175 DefKind::EnumVariant => Def::EnumVariant(EnumVariant::new(self)), 178 DefKind::EnumVariant => Def::EnumVariant(EnumVariant::new(self)),
179 DefKind::Const => {
180 let def = Const::new(self);
181 Def::Const(def)
182 }
183 DefKind::Static => {
184 let def = Static::new(self);
185 Def::Static(def)
186 }
187 DefKind::Trait => {
188 let def = Trait::new(self);
189 Def::Trait(def)
190 }
191 DefKind::Type => {
192 let def = Type::new(self);
193 Def::Type(def)
194 }
195
176 DefKind::StructCtor => Def::Item, 196 DefKind::StructCtor => Def::Item,
177 DefKind::Item => Def::Item, 197 DefKind::Item => Def::Item,
178 }; 198 };
@@ -218,10 +238,10 @@ impl DefKind {
218 SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor), 238 SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor),
219 SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum), 239 SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum),
220 // These define items, but don't have their own DefKinds yet: 240 // These define items, but don't have their own DefKinds yet:
221 SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Item), 241 SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait),
222 SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Item), 242 SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type),
223 SyntaxKind::CONST_DEF => PerNs::values(DefKind::Item), 243 SyntaxKind::CONST_DEF => PerNs::values(DefKind::Const),
224 SyntaxKind::STATIC_DEF => PerNs::values(DefKind::Item), 244 SyntaxKind::STATIC_DEF => PerNs::values(DefKind::Static),
225 _ => PerNs::none(), 245 _ => PerNs::none(),
226 } 246 }
227 } 247 }