aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorAramis Razzaghipour <[email protected]>2021-05-23 14:45:26 +0100
committerAramis Razzaghipour <[email protected]>2021-05-24 05:53:48 +0100
commit4fd5248749202e0578d719bc5480171a85358836 (patch)
tree69d1e6928bb9b7fa527835703890c4ee5343e5ca /crates/hir
parent064ff633f6055ed35022222c89af01d3f9943e3c (diff)
Add highlighting of items from other crates
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs17
1 files changed, 17 insertions, 0 deletions
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 {
673 pub fn module(self, db: &dyn HirDatabase) -> Module { 673 pub fn module(self, db: &dyn HirDatabase) -> Module {
674 self.parent.module(db) 674 self.parent.module(db)
675 } 675 }
676
677 pub fn krate(self, db: &dyn HirDatabase) -> Crate {
678 self.module(db).krate()
679 }
680
676 pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum { 681 pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum {
677 self.parent 682 self.parent
678 } 683 }
@@ -767,6 +772,10 @@ impl VariantDef {
767 } 772 }
768 } 773 }
769 774
775 pub fn krate(self, db: &dyn HirDatabase) -> Crate {
776 self.module(db).krate()
777 }
778
770 pub fn name(&self, db: &dyn HirDatabase) -> Name { 779 pub fn name(&self, db: &dyn HirDatabase) -> Name {
771 match self { 780 match self {
772 VariantDef::Struct(s) => s.name(db), 781 VariantDef::Struct(s) => s.name(db),
@@ -1074,6 +1083,10 @@ impl Trait {
1074 Module { id: self.id.lookup(db.upcast()).container } 1083 Module { id: self.id.lookup(db.upcast()).container }
1075 } 1084 }
1076 1085
1086 pub fn krate(self, db: &dyn HirDatabase) -> Crate {
1087 self.module(db).krate()
1088 }
1089
1077 pub fn name(self, db: &dyn HirDatabase) -> Name { 1090 pub fn name(self, db: &dyn HirDatabase) -> Name {
1078 db.trait_data(self.id).name.clone() 1091 db.trait_data(self.id).name.clone()
1079 } 1092 }
@@ -1178,6 +1191,10 @@ impl MacroDef {
1178 Some(Module { id: def_map.module_id(module_id) }) 1191 Some(Module { id: def_map.module_id(module_id) })
1179 } 1192 }
1180 1193
1194 pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
1195 self.module(db).map(Module::krate)
1196 }
1197
1181 /// XXX: this parses the file 1198 /// XXX: this parses the file
1182 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { 1199 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
1183 match self.source(db)?.value { 1200 match self.source(db)?.value {