aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/src.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/src.rs')
-rw-r--r--crates/ra_hir_def/src/src.rs41
1 files changed, 40 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/src.rs b/crates/ra_hir_def/src/src.rs
index a5c4359a7..20200d1db 100644
--- a/crates/ra_hir_def/src/src.rs
+++ b/crates/ra_hir_def/src/src.rs
@@ -4,7 +4,10 @@ use hir_expand::InFile;
4use ra_arena::map::ArenaMap; 4use ra_arena::map::ArenaMap;
5use ra_syntax::ast; 5use ra_syntax::ast;
6 6
7use crate::{db::DefDatabase, ConstLoc, FunctionLoc, ImplLoc, StaticLoc, TypeAliasLoc}; 7use crate::{
8 db::DefDatabase, ConstLoc, EnumLoc, FunctionLoc, ImplLoc, StaticLoc, StructLoc, TraitLoc,
9 TypeAliasLoc, UnionLoc,
10};
8 11
9pub trait HasSource { 12pub trait HasSource {
10 type Value; 13 type Value;
@@ -56,6 +59,42 @@ impl HasSource for ImplLoc {
56 } 59 }
57} 60}
58 61
62impl HasSource for TraitLoc {
63 type Value = ast::TraitDef;
64
65 fn source(&self, db: &impl DefDatabase) -> InFile<ast::TraitDef> {
66 let node = self.ast_id.to_node(db);
67 InFile::new(self.ast_id.file_id, node)
68 }
69}
70
71impl HasSource for StructLoc {
72 type Value = ast::StructDef;
73
74 fn source(&self, db: &impl DefDatabase) -> InFile<ast::StructDef> {
75 let node = self.ast_id.to_node(db);
76 InFile::new(self.ast_id.file_id, node)
77 }
78}
79
80impl HasSource for UnionLoc {
81 type Value = ast::UnionDef;
82
83 fn source(&self, db: &impl DefDatabase) -> InFile<ast::UnionDef> {
84 let node = self.ast_id.to_node(db);
85 InFile::new(self.ast_id.file_id, node)
86 }
87}
88
89impl HasSource for EnumLoc {
90 type Value = ast::EnumDef;
91
92 fn source(&self, db: &impl DefDatabase) -> InFile<ast::EnumDef> {
93 let node = self.ast_id.to_node(db);
94 InFile::new(self.ast_id.file_id, node)
95 }
96}
97
59pub trait HasChildSource { 98pub trait HasChildSource {
60 type ChildId; 99 type ChildId;
61 type Value; 100 type Value;