diff options
author | Aleksey Kladov <[email protected]> | 2019-11-02 20:11:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-02 20:11:27 +0000 |
commit | b8533413cf082f2d942b78af841e3895db252106 (patch) | |
tree | 605fd62c88d8ec612c8bcc42dbf0f0206272f633 /crates/ra_hir_def | |
parent | 2d142a17efed6a1445cdc86f2f4abb329f54a140 (diff) |
Move Source to hir_expand
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 76d5f1852..6d66f481d 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -19,19 +19,13 @@ pub mod nameres; | |||
19 | 19 | ||
20 | use std::hash::{Hash, Hasher}; | 20 | use std::hash::{Hash, Hasher}; |
21 | 21 | ||
22 | use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId}; | 22 | use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, Source}; |
23 | use ra_arena::{impl_arena_id, RawId}; | 23 | use ra_arena::{impl_arena_id, RawId}; |
24 | use ra_db::{salsa, CrateId, FileId}; | 24 | use ra_db::{salsa, CrateId, FileId}; |
25 | use ra_syntax::{ast, AstNode, SyntaxNode}; | 25 | use ra_syntax::{ast, AstNode, SyntaxNode}; |
26 | 26 | ||
27 | use crate::{builtin_type::BuiltinType, db::InternDatabase}; | 27 | use crate::{builtin_type::BuiltinType, db::InternDatabase}; |
28 | 28 | ||
29 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
30 | pub struct Source<T> { | ||
31 | pub file_id: HirFileId, | ||
32 | pub ast: T, | ||
33 | } | ||
34 | |||
35 | pub enum ModuleSource { | 29 | pub enum ModuleSource { |
36 | SourceFile(ast::SourceFile), | 30 | SourceFile(ast::SourceFile), |
37 | Module(ast::Module), | 31 | Module(ast::Module), |
@@ -94,15 +88,6 @@ impl ModuleSource { | |||
94 | } | 88 | } |
95 | } | 89 | } |
96 | 90 | ||
97 | impl<T> Source<T> { | ||
98 | pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { | ||
99 | Source { file_id: self.file_id, ast: f(self.ast) } | ||
100 | } | ||
101 | pub fn file_syntax(&self, db: &impl AstDatabase) -> SyntaxNode { | ||
102 | db.parse_or_expand(self.file_id).expect("source created from invalid file") | ||
103 | } | ||
104 | } | ||
105 | |||
106 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 91 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
107 | pub struct ModuleId { | 92 | pub struct ModuleId { |
108 | pub krate: CrateId, | 93 | pub krate: CrateId, |