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