mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Merge #788
788: remove query_definitions r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
af62fde57f
4 changed files with 20 additions and 34 deletions
|
@ -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<HirInterner> {
|
|||
#[salsa::invoke(crate::adt::EnumData::enum_data_query)]
|
||||
fn enum_data(&self, e: Enum) -> Arc<EnumData>;
|
||||
|
||||
#[salsa::invoke(query_definitions::file_items)]
|
||||
#[salsa::invoke(crate::ids::SourceFileItems::file_items_query)]
|
||||
fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>;
|
||||
|
||||
#[salsa::invoke(query_definitions::file_item)]
|
||||
#[salsa::invoke(crate::ids::SourceFileItems::file_item_query)]
|
||||
fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>;
|
||||
|
||||
#[salsa::invoke(crate::module_tree::Submodule::submodules_query)]
|
||||
|
|
|
@ -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<SourceFileItems> {
|
||||
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<SyntaxNode> {
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<SourceFileItems> {
|
||||
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<SyntaxNode> {
|
||||
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()
|
||||
}
|
Loading…
Reference in a new issue