diff options
author | Aleksey Kladov <[email protected]> | 2019-02-11 14:44:54 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-11 14:44:54 +0000 |
commit | 28fd228c70c8fef82abc90e7077e1a98322c7c2d (patch) | |
tree | 0114f822b36c5b898aba873af277a33b5f4bbc04 /crates/ra_hir/src | |
parent | 6596793c0ce24b10c599b7d8b34483595d9a4511 (diff) |
remove query_definitions
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/db.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 27 |
4 files changed, 20 insertions, 34 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index e03632519..740a7be7a 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -6,7 +6,6 @@ use ra_db::{SourceDatabase, salsa}; | |||
6 | use crate::{ | 6 | use crate::{ |
7 | MacroCallId, HirFileId, | 7 | MacroCallId, HirFileId, |
8 | SourceFileItems, SourceItemId, Crate, Module, HirInterner, | 8 | SourceFileItems, SourceItemId, Crate, Module, HirInterner, |
9 | query_definitions, | ||
10 | Function, FnSignature, ExprScopes, | 9 | Function, FnSignature, ExprScopes, |
11 | Struct, Enum, StructField, | 10 | Struct, Enum, StructField, |
12 | macros::MacroExpansion, | 11 | macros::MacroExpansion, |
@@ -33,10 +32,10 @@ pub trait PersistentHirDatabase: SourceDatabase + AsRef<HirInterner> { | |||
33 | #[salsa::invoke(crate::adt::EnumData::enum_data_query)] | 32 | #[salsa::invoke(crate::adt::EnumData::enum_data_query)] |
34 | fn enum_data(&self, e: Enum) -> Arc<EnumData>; | 33 | fn enum_data(&self, e: Enum) -> Arc<EnumData>; |
35 | 34 | ||
36 | #[salsa::invoke(query_definitions::file_items)] | 35 | #[salsa::invoke(crate::ids::SourceFileItems::file_items_query)] |
37 | fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>; | 36 | fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>; |
38 | 37 | ||
39 | #[salsa::invoke(query_definitions::file_item)] | 38 | #[salsa::invoke(crate::ids::SourceFileItems::file_item_query)] |
40 | fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>; | 39 | fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>; |
41 | 40 | ||
42 | #[salsa::invoke(crate::module_tree::Submodule::submodules_query)] | 41 | #[salsa::invoke(crate::module_tree::Submodule::submodules_query)] |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index ea13c1196..d3fa7d266 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | marker::PhantomData, | 2 | marker::PhantomData, |
3 | hash::{Hash, Hasher}, | 3 | hash::{Hash, Hasher}, |
4 | sync::Arc, | ||
4 | }; | 5 | }; |
5 | 6 | ||
6 | use ra_db::{LocationIntener, FileId}; | 7 | use ra_db::{LocationIntener, FileId}; |
@@ -301,10 +302,24 @@ pub struct SourceFileItems { | |||
301 | } | 302 | } |
302 | 303 | ||
303 | impl SourceFileItems { | 304 | impl SourceFileItems { |
304 | pub(crate) fn new(file_id: HirFileId, source_file: &SourceFile) -> SourceFileItems { | 305 | pub(crate) fn file_items_query( |
306 | db: &impl PersistentHirDatabase, | ||
307 | file_id: HirFileId, | ||
308 | ) -> Arc<SourceFileItems> { | ||
309 | let source_file = db.hir_parse(file_id); | ||
305 | let mut res = SourceFileItems { file_id, arena: Arena::default() }; | 310 | let mut res = SourceFileItems { file_id, arena: Arena::default() }; |
306 | res.init(source_file); | 311 | res.init(&source_file); |
307 | res | 312 | Arc::new(res) |
313 | } | ||
314 | |||
315 | pub(crate) fn file_item_query( | ||
316 | db: &impl PersistentHirDatabase, | ||
317 | source_item_id: SourceItemId, | ||
318 | ) -> TreeArc<SyntaxNode> { | ||
319 | let source_file = db.hir_parse(source_item_id.file_id); | ||
320 | db.file_items(source_item_id.file_id)[source_item_id.item_id] | ||
321 | .to_node(&source_file) | ||
322 | .to_owned() | ||
308 | } | 323 | } |
309 | 324 | ||
310 | fn init(&mut self, source_file: &SourceFile) { | 325 | fn init(&mut self, source_file: &SourceFile) { |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 8ed8c4bdc..b212c3399 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -20,7 +20,6 @@ macro_rules! impl_froms { | |||
20 | pub mod db; | 20 | pub mod db; |
21 | #[macro_use] | 21 | #[macro_use] |
22 | pub mod mock; | 22 | pub mod mock; |
23 | mod query_definitions; | ||
24 | mod path; | 23 | mod path; |
25 | pub mod source_binder; | 24 | pub mod source_binder; |
26 | 25 | ||
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs deleted file mode 100644 index 03113e7cc..000000000 --- a/crates/ra_hir/src/query_definitions.rs +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | use std::sync::Arc; | ||
2 | |||
3 | use ra_syntax::{ | ||
4 | SyntaxNode, TreeArc, | ||
5 | }; | ||
6 | |||
7 | use crate::{ | ||
8 | SourceFileItems, SourceItemId, HirFileId, | ||
9 | PersistentHirDatabase, | ||
10 | }; | ||
11 | |||
12 | pub(super) fn file_items( | ||
13 | db: &impl PersistentHirDatabase, | ||
14 | file_id: HirFileId, | ||
15 | ) -> Arc<SourceFileItems> { | ||
16 | let source_file = db.hir_parse(file_id); | ||
17 | let res = SourceFileItems::new(file_id, &source_file); | ||
18 | Arc::new(res) | ||
19 | } | ||
20 | |||
21 | pub(super) fn file_item( | ||
22 | db: &impl PersistentHirDatabase, | ||
23 | source_item_id: SourceItemId, | ||
24 | ) -> TreeArc<SyntaxNode> { | ||
25 | let source_file = db.hir_parse(source_item_id.file_id); | ||
26 | db.file_items(source_item_id.file_id)[source_item_id.item_id].to_node(&source_file).to_owned() | ||
27 | } | ||