diff options
Diffstat (limited to 'crates/ra_hir_def/src/src.rs')
-rw-r--r-- | crates/ra_hir_def/src/src.rs | 41 |
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; | |||
4 | use ra_arena::map::ArenaMap; | 4 | use ra_arena::map::ArenaMap; |
5 | use ra_syntax::ast; | 5 | use ra_syntax::ast; |
6 | 6 | ||
7 | use crate::{db::DefDatabase, ConstLoc, FunctionLoc, ImplLoc, StaticLoc, TypeAliasLoc}; | 7 | use crate::{ |
8 | db::DefDatabase, ConstLoc, EnumLoc, FunctionLoc, ImplLoc, StaticLoc, StructLoc, TraitLoc, | ||
9 | TypeAliasLoc, UnionLoc, | ||
10 | }; | ||
8 | 11 | ||
9 | pub trait HasSource { | 12 | pub trait HasSource { |
10 | type Value; | 13 | type Value; |
@@ -56,6 +59,42 @@ impl HasSource for ImplLoc { | |||
56 | } | 59 | } |
57 | } | 60 | } |
58 | 61 | ||
62 | impl 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 | |||
71 | impl 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 | |||
80 | impl 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 | |||
89 | impl 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 | |||
59 | pub trait HasChildSource { | 98 | pub trait HasChildSource { |
60 | type ChildId; | 99 | type ChildId; |
61 | type Value; | 100 | type Value; |