diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-02 10:32:26 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-02 10:32:26 +0100 |
commit | 82cf27b5fc91a4125315d28b8a3c86e5fa7be26d (patch) | |
tree | c6f5e240d385fd33f25a70d20b8244a721202264 /crates/ra_hir/src/source_id.rs | |
parent | 8256dfdd713451cbe54ee61a176b79f1d1bab589 (diff) | |
parent | 5af9e475f4acce54f8383ed22febc412cf2541d0 (diff) |
Merge #1362
1362: Introduce AST database r=matklad a=matklad
The idea here is to separate fragile bits which look into the syntax directly from robust bits which are safe across reparses. This uses the new `salsa::requires` featue
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/source_id.rs')
-rw-r--r-- | crates/ra_hir/src/source_id.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs index 13f548eaf..986269e00 100644 --- a/crates/ra_hir/src/source_id.rs +++ b/crates/ra_hir/src/source_id.rs | |||
@@ -3,7 +3,7 @@ use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}}; | |||
3 | use ra_arena::{Arena, RawId, impl_arena_id}; | 3 | use ra_arena::{Arena, RawId, impl_arena_id}; |
4 | use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast}; | 4 | use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast}; |
5 | 5 | ||
6 | use crate::{HirFileId, DefDatabase}; | 6 | use crate::{HirFileId, AstDatabase}; |
7 | 7 | ||
8 | /// `AstId` points to an AST node in any file. | 8 | /// `AstId` points to an AST node in any file. |
9 | /// | 9 | /// |
@@ -38,7 +38,7 @@ impl<N: AstNode> AstId<N> { | |||
38 | self.file_id | 38 | self.file_id |
39 | } | 39 | } |
40 | 40 | ||
41 | pub(crate) fn to_node(&self, db: &impl DefDatabase) -> TreeArc<N> { | 41 | pub(crate) fn to_node(&self, db: &impl AstDatabase) -> TreeArc<N> { |
42 | let syntax_node = db.ast_id_to_node(self.file_id, self.file_ast_id.raw); | 42 | let syntax_node = db.ast_id_to_node(self.file_id, self.file_ast_id.raw); |
43 | N::cast(&syntax_node).unwrap().to_owned() | 43 | N::cast(&syntax_node).unwrap().to_owned() |
44 | } | 44 | } |
@@ -87,7 +87,7 @@ pub struct AstIdMap { | |||
87 | } | 87 | } |
88 | 88 | ||
89 | impl AstIdMap { | 89 | impl AstIdMap { |
90 | pub(crate) fn ast_id_map_query(db: &impl DefDatabase, file_id: HirFileId) -> Arc<AstIdMap> { | 90 | pub(crate) fn ast_id_map_query(db: &impl AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { |
91 | let map = if let Some(node) = db.parse_or_expand(file_id) { | 91 | let map = if let Some(node) = db.parse_or_expand(file_id) { |
92 | AstIdMap::from_source(&*node) | 92 | AstIdMap::from_source(&*node) |
93 | } else { | 93 | } else { |
@@ -97,7 +97,7 @@ impl AstIdMap { | |||
97 | } | 97 | } |
98 | 98 | ||
99 | pub(crate) fn file_item_query( | 99 | pub(crate) fn file_item_query( |
100 | db: &impl DefDatabase, | 100 | db: &impl AstDatabase, |
101 | file_id: HirFileId, | 101 | file_id: HirFileId, |
102 | ast_id: ErasedFileAstId, | 102 | ast_id: ErasedFileAstId, |
103 | ) -> TreeArc<SyntaxNode> { | 103 | ) -> TreeArc<SyntaxNode> { |