From 28fd228c70c8fef82abc90e7077e1a98322c7c2d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 11 Feb 2019 17:44:54 +0300 Subject: remove query_definitions --- crates/ra_hir/src/db.rs | 5 ++--- crates/ra_hir/src/ids.rs | 21 ++++++++++++++++++--- crates/ra_hir/src/lib.rs | 1 - crates/ra_hir/src/query_definitions.rs | 27 --------------------------- 4 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 crates/ra_hir/src/query_definitions.rs (limited to 'crates/ra_hir/src') 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}; use crate::{ MacroCallId, HirFileId, SourceFileItems, SourceItemId, Crate, Module, HirInterner, - query_definitions, Function, FnSignature, ExprScopes, Struct, Enum, StructField, macros::MacroExpansion, @@ -33,10 +32,10 @@ pub trait PersistentHirDatabase: SourceDatabase + AsRef { #[salsa::invoke(crate::adt::EnumData::enum_data_query)] fn enum_data(&self, e: Enum) -> Arc; - #[salsa::invoke(query_definitions::file_items)] + #[salsa::invoke(crate::ids::SourceFileItems::file_items_query)] fn file_items(&self, file_id: HirFileId) -> Arc; - #[salsa::invoke(query_definitions::file_item)] + #[salsa::invoke(crate::ids::SourceFileItems::file_item_query)] fn file_item(&self, source_item_id: SourceItemId) -> TreeArc; #[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 @@ use std::{ marker::PhantomData, hash::{Hash, Hasher}, + sync::Arc, }; use ra_db::{LocationIntener, FileId}; @@ -301,10 +302,24 @@ pub struct SourceFileItems { } impl SourceFileItems { - pub(crate) fn new(file_id: HirFileId, source_file: &SourceFile) -> SourceFileItems { + pub(crate) fn file_items_query( + db: &impl PersistentHirDatabase, + file_id: HirFileId, + ) -> Arc { + let source_file = db.hir_parse(file_id); let mut res = SourceFileItems { file_id, arena: Arena::default() }; - res.init(source_file); - res + res.init(&source_file); + Arc::new(res) + } + + pub(crate) fn file_item_query( + db: &impl PersistentHirDatabase, + source_item_id: SourceItemId, + ) -> TreeArc { + let source_file = db.hir_parse(source_item_id.file_id); + db.file_items(source_item_id.file_id)[source_item_id.item_id] + .to_node(&source_file) + .to_owned() } 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 { pub mod db; #[macro_use] pub mod mock; -mod query_definitions; mod path; pub mod source_binder; 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 @@ -use std::sync::Arc; - -use ra_syntax::{ - SyntaxNode, TreeArc, -}; - -use crate::{ - SourceFileItems, SourceItemId, HirFileId, - PersistentHirDatabase, -}; - -pub(super) fn file_items( - db: &impl PersistentHirDatabase, - file_id: HirFileId, -) -> Arc { - let source_file = db.hir_parse(file_id); - let res = SourceFileItems::new(file_id, &source_file); - Arc::new(res) -} - -pub(super) fn file_item( - db: &impl PersistentHirDatabase, - source_item_id: SourceItemId, -) -> TreeArc { - let source_file = db.hir_parse(source_item_id.file_id); - db.file_items(source_item_id.file_id)[source_item_id.item_id].to_node(&source_file).to_owned() -} -- cgit v1.2.3