From 4fd5248749202e0578d719bc5480171a85358836 Mon Sep 17 00:00:00 2001 From: Aramis Razzaghipour Date: Sun, 23 May 2021 23:45:26 +1000 Subject: Add highlighting of items from other crates --- crates/hir/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index a7c42ca1e..6522a924b 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -673,6 +673,11 @@ impl Variant { pub fn module(self, db: &dyn HirDatabase) -> Module { self.parent.module(db) } + + pub fn krate(self, db: &dyn HirDatabase) -> Crate { + self.module(db).krate() + } + pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum { self.parent } @@ -767,6 +772,10 @@ impl VariantDef { } } + pub fn krate(self, db: &dyn HirDatabase) -> Crate { + self.module(db).krate() + } + pub fn name(&self, db: &dyn HirDatabase) -> Name { match self { VariantDef::Struct(s) => s.name(db), @@ -1074,6 +1083,10 @@ impl Trait { Module { id: self.id.lookup(db.upcast()).container } } + pub fn krate(self, db: &dyn HirDatabase) -> Crate { + self.module(db).krate() + } + pub fn name(self, db: &dyn HirDatabase) -> Name { db.trait_data(self.id).name.clone() } @@ -1178,6 +1191,10 @@ impl MacroDef { Some(Module { id: def_map.module_id(module_id) }) } + pub fn krate(self, db: &dyn HirDatabase) -> Option { + self.module(db).map(Module::krate) + } + /// XXX: this parses the file pub fn name(self, db: &dyn HirDatabase) -> Option { match self.source(db)?.value { -- cgit v1.2.3 From c32428571c3fbf12bd4a4187c797488355416a18 Mon Sep 17 00:00:00 2001 From: Aramis Razzaghipour Date: Mon, 24 May 2021 09:42:06 +1000 Subject: Remove hir krate methods --- crates/hir/src/lib.rs | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 6522a924b..ec5f0c53d 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -552,10 +552,6 @@ impl Struct { Module { id: self.id.lookup(db.upcast()).container } } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - Some(self.module(db).krate()) - } - pub fn name(self, db: &dyn HirDatabase) -> Name { db.struct_data(self.id).name.clone() } @@ -640,10 +636,6 @@ impl Enum { Module { id: self.id.lookup(db.upcast()).container } } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - Some(self.module(db).krate()) - } - pub fn name(self, db: &dyn HirDatabase) -> Name { db.enum_data(self.id).name.clone() } @@ -674,10 +666,6 @@ impl Variant { self.parent.module(db) } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - self.module(db).krate() - } - pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum { self.parent } @@ -734,10 +722,6 @@ impl Adt { } } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - self.module(db).krate() - } - pub fn name(self, db: &dyn HirDatabase) -> Name { match self { Adt::Struct(s) => s.name(db), @@ -772,10 +756,6 @@ impl VariantDef { } } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - self.module(db).krate() - } - pub fn name(&self, db: &dyn HirDatabase) -> Name { match self { VariantDef::Struct(s) => s.name(db), @@ -830,10 +810,6 @@ impl Function { self.id.lookup(db.upcast()).module(db.upcast()).into() } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - Some(self.module(db).krate()) - } - pub fn name(self, db: &dyn HirDatabase) -> Name { db.function_data(self.id).name.clone() } @@ -1023,10 +999,6 @@ impl Const { Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - Some(self.module(db).krate()) - } - pub fn name(self, db: &dyn HirDatabase) -> Option { db.const_data(self.id).name.clone() } @@ -1054,10 +1026,6 @@ impl Static { Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - Some(self.module(db).krate()) - } - pub fn name(self, db: &dyn HirDatabase) -> Option { db.static_data(self.id).name.clone() } @@ -1083,10 +1051,6 @@ impl Trait { Module { id: self.id.lookup(db.upcast()).container } } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - self.module(db).krate() - } - pub fn name(self, db: &dyn HirDatabase) -> Name { db.trait_data(self.id).name.clone() } @@ -1125,10 +1089,6 @@ impl TypeAlias { Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - self.module(db).krate() - } - pub fn type_ref(self, db: &dyn HirDatabase) -> Option { db.type_alias_data(self.id).type_ref.as_deref().cloned() } @@ -1191,10 +1151,6 @@ impl MacroDef { Some(Module { id: def_map.module_id(module_id) }) } - pub fn krate(self, db: &dyn HirDatabase) -> Option { - self.module(db).map(Module::krate) - } - /// XXX: this parses the file pub fn name(self, db: &dyn HirDatabase) -> Option { match self.source(db)?.value { @@ -1684,10 +1640,6 @@ impl Impl { self.id.lookup(db.upcast()).container.into() } - pub fn krate(self, db: &dyn HirDatabase) -> Crate { - Crate { id: self.module(db).id.krate() } - } - pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option> { let src = self.source(db)?; let item = src.file_id.is_builtin_derive(db.upcast())?; -- cgit v1.2.3