diff options
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 6daf7d3a3..cfeacfded 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -29,6 +29,8 @@ pub mod resolver; | |||
29 | mod trace; | 29 | mod trace; |
30 | pub mod nameres; | 30 | pub mod nameres; |
31 | 31 | ||
32 | pub mod src; | ||
33 | |||
32 | #[cfg(test)] | 34 | #[cfg(test)] |
33 | mod test_db; | 35 | mod test_db; |
34 | #[cfg(test)] | 36 | #[cfg(test)] |
@@ -37,7 +39,7 @@ mod marks; | |||
37 | use std::hash::{Hash, Hasher}; | 39 | use std::hash::{Hash, Hasher}; |
38 | 40 | ||
39 | use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, InFile, MacroDefId}; | 41 | use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, InFile, MacroDefId}; |
40 | use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; | 42 | use ra_arena::{impl_arena_id, RawId}; |
41 | use ra_db::{impl_intern_key, salsa, CrateId}; | 43 | use ra_db::{impl_intern_key, salsa, CrateId}; |
42 | use ra_syntax::{ast, AstNode}; | 44 | use ra_syntax::{ast, AstNode}; |
43 | 45 | ||
@@ -514,53 +516,3 @@ impl HasModule for StaticLoc { | |||
514 | self.container | 516 | self.container |
515 | } | 517 | } |
516 | } | 518 | } |
517 | |||
518 | pub trait HasSource { | ||
519 | type Value; | ||
520 | fn source(&self, db: &impl db::DefDatabase) -> InFile<Self::Value>; | ||
521 | } | ||
522 | |||
523 | impl HasSource for FunctionLoc { | ||
524 | type Value = ast::FnDef; | ||
525 | |||
526 | fn source(&self, db: &impl db::DefDatabase) -> InFile<ast::FnDef> { | ||
527 | let node = self.ast_id.to_node(db); | ||
528 | InFile::new(self.ast_id.file_id, node) | ||
529 | } | ||
530 | } | ||
531 | |||
532 | impl HasSource for TypeAliasLoc { | ||
533 | type Value = ast::TypeAliasDef; | ||
534 | |||
535 | fn source(&self, db: &impl db::DefDatabase) -> InFile<ast::TypeAliasDef> { | ||
536 | let node = self.ast_id.to_node(db); | ||
537 | InFile::new(self.ast_id.file_id, node) | ||
538 | } | ||
539 | } | ||
540 | |||
541 | impl HasSource for ConstLoc { | ||
542 | type Value = ast::ConstDef; | ||
543 | |||
544 | fn source(&self, db: &impl db::DefDatabase) -> InFile<ast::ConstDef> { | ||
545 | let node = self.ast_id.to_node(db); | ||
546 | InFile::new(self.ast_id.file_id, node) | ||
547 | } | ||
548 | } | ||
549 | |||
550 | impl HasSource for StaticLoc { | ||
551 | type Value = ast::StaticDef; | ||
552 | |||
553 | fn source(&self, db: &impl db::DefDatabase) -> InFile<ast::StaticDef> { | ||
554 | let node = self.ast_id.to_node(db); | ||
555 | InFile::new(self.ast_id.file_id, node) | ||
556 | } | ||
557 | } | ||
558 | |||
559 | pub trait HasChildSource { | ||
560 | type ChildId; | ||
561 | type Value; | ||
562 | fn child_source( | ||
563 | &self, | ||
564 | db: &impl db::DefDatabase, | ||
565 | ) -> InFile<ArenaMap<Self::ChildId, Self::Value>>; | ||
566 | } | ||