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/ids.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/ids.rs') 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}; use crate::{ HirDatabase, PerNs, Def, Function, Struct, Enum, EnumVariant, ImplBlock, Crate, + Module, Trait, Type, Static, Const, module_tree::ModuleId, }; -use crate::code_model_api::Module; - /// hir makes heavy use of ids: integer (u32) handlers to various things. You /// can think of id as a pointer (but without a lifetime) or a file descriptor /// (but for hir objects). @@ -146,6 +145,10 @@ pub(crate) enum DefKind { Struct, Enum, EnumVariant, + Const, + Static, + Trait, + Type, Item, StructCtor, @@ -173,6 +176,23 @@ impl DefId { } DefKind::Enum => Def::Enum(Enum::new(self)), DefKind::EnumVariant => Def::EnumVariant(EnumVariant::new(self)), + DefKind::Const => { + let def = Const::new(self); + Def::Const(def) + } + DefKind::Static => { + let def = Static::new(self); + Def::Static(def) + } + DefKind::Trait => { + let def = Trait::new(self); + Def::Trait(def) + } + DefKind::Type => { + let def = Type::new(self); + Def::Type(def) + } + DefKind::StructCtor => Def::Item, DefKind::Item => Def::Item, }; @@ -218,10 +238,10 @@ impl DefKind { SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor), SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum), // These define items, but don't have their own DefKinds yet: - SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Item), - SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Item), - SyntaxKind::CONST_DEF => PerNs::values(DefKind::Item), - SyntaxKind::STATIC_DEF => PerNs::values(DefKind::Item), + SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait), + SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type), + SyntaxKind::CONST_DEF => PerNs::values(DefKind::Const), + SyntaxKind::STATIC_DEF => PerNs::values(DefKind::Static), _ => PerNs::none(), } } -- cgit v1.2.3