mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
move item_map_query
This commit is contained in:
parent
b704ce803b
commit
95aa7e46fc
3 changed files with 29 additions and 35 deletions
|
@ -67,7 +67,7 @@ pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
|
||||||
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
|
||||||
fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>;
|
fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>;
|
||||||
|
|
||||||
#[salsa::invoke(query_definitions::item_map)]
|
#[salsa::invoke(crate::nameres::ItemMap::item_map_query)]
|
||||||
fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>;
|
fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>;
|
||||||
|
|
||||||
#[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
|
#[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
//! structure itself is modified.
|
//! structure itself is modified.
|
||||||
pub(crate) mod lower;
|
pub(crate) mod lower;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::{time, sync::Arc};
|
||||||
|
|
||||||
use ra_db::CrateId;
|
use ra_db::CrateId;
|
||||||
use ra_arena::map::ArenaMap;
|
use ra_arena::map::ArenaMap;
|
||||||
|
@ -156,7 +156,7 @@ impl<T> PerNs<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct Resolver<'a, DB> {
|
struct Resolver<'a, DB> {
|
||||||
db: &'a DB,
|
db: &'a DB,
|
||||||
input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>,
|
input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
|
@ -169,7 +169,7 @@ impl<'a, DB> Resolver<'a, DB>
|
||||||
where
|
where
|
||||||
DB: HirDatabase,
|
DB: HirDatabase,
|
||||||
{
|
{
|
||||||
pub(crate) fn new(
|
fn new(
|
||||||
db: &'a DB,
|
db: &'a DB,
|
||||||
input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>,
|
input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
|
@ -331,6 +331,29 @@ enum ReachedFixedPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemMap {
|
impl ItemMap {
|
||||||
|
pub(crate) fn item_map_query(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ItemMap> {
|
||||||
|
let start = time::Instant::now();
|
||||||
|
let module_tree = db.module_tree(crate_id);
|
||||||
|
let input = module_tree
|
||||||
|
.modules()
|
||||||
|
.map(|module_id| {
|
||||||
|
(
|
||||||
|
module_id,
|
||||||
|
db.lower_module_module(Module {
|
||||||
|
krate: crate_id,
|
||||||
|
module_id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<FxHashMap<_, _>>();
|
||||||
|
|
||||||
|
let resolver = Resolver::new(db, &input, crate_id);
|
||||||
|
let res = resolver.resolve();
|
||||||
|
let elapsed = start.elapsed();
|
||||||
|
log::info!("item_map: {:?}", elapsed);
|
||||||
|
Arc::new(res)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn resolve_path(
|
pub(crate) fn resolve_path(
|
||||||
&self,
|
&self,
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
use std::{
|
use std::sync::Arc;
|
||||||
sync::Arc,
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
|
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use ra_syntax::{SyntaxNode, TreeArc};
|
use ra_syntax::{SyntaxNode, TreeArc};
|
||||||
use ra_db::{CrateId};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
SourceFileItems, SourceItemId, HirFileId,
|
SourceFileItems, SourceItemId, HirFileId,
|
||||||
Function, FnScopes, Module,
|
Function, FnScopes,
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
nameres::{ItemMap, Resolver},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> {
|
pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> {
|
||||||
|
@ -35,26 +29,3 @@ pub(super) fn file_item(
|
||||||
.to_node(&source_file)
|
.to_node(&source_file)
|
||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn item_map(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ItemMap> {
|
|
||||||
let start = Instant::now();
|
|
||||||
let module_tree = db.module_tree(crate_id);
|
|
||||||
let input = module_tree
|
|
||||||
.modules()
|
|
||||||
.map(|module_id| {
|
|
||||||
(
|
|
||||||
module_id,
|
|
||||||
db.lower_module_module(Module {
|
|
||||||
krate: crate_id,
|
|
||||||
module_id,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<FxHashMap<_, _>>();
|
|
||||||
|
|
||||||
let resolver = Resolver::new(db, &input, crate_id);
|
|
||||||
let res = resolver.resolve();
|
|
||||||
let elapsed = start.elapsed();
|
|
||||||
log::info!("item_map: {:?}", elapsed);
|
|
||||||
Arc::new(res)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue