aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/db.rs5
-rw-r--r--crates/ra_hir/src/ids.rs21
-rw-r--r--crates/ra_hir/src/lib.rs1
-rw-r--r--crates/ra_hir/src/query_definitions.rs27
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};
6use crate::{ 6use 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 @@
1use std::{ 1use std::{
2 marker::PhantomData, 2 marker::PhantomData,
3 hash::{Hash, Hasher}, 3 hash::{Hash, Hasher},
4 sync::Arc,
4}; 5};
5 6
6use ra_db::{LocationIntener, FileId}; 7use ra_db::{LocationIntener, FileId};
@@ -301,10 +302,24 @@ pub struct SourceFileItems {
301} 302}
302 303
303impl SourceFileItems { 304impl 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 {
20pub mod db; 20pub mod db;
21#[macro_use] 21#[macro_use]
22pub mod mock; 22pub mod mock;
23mod query_definitions;
24mod path; 23mod path;
25pub mod source_binder; 24pub 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 @@
1use std::sync::Arc;
2
3use ra_syntax::{
4 SyntaxNode, TreeArc,
5};
6
7use crate::{
8 SourceFileItems, SourceItemId, HirFileId,
9 PersistentHirDatabase,
10};
11
12pub(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
21pub(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}