From 3ab1519cb27b927074ed7fbbb18a856e6e7fabb8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 23 Jan 2019 23:14:13 +0300 Subject: Change ids strategy this is a part of larghish hir refactoring which aims to * replace per-source-root module trees with per crate trees * switch from a monotyped DedId to type-specific ids --- crates/ra_hir/src/query_definitions.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/query_definitions.rs') diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 074153862..a8ed887b3 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -7,11 +7,11 @@ use rustc_hash::FxHashMap; use ra_syntax::{ AstNode, SyntaxNode, TreeArc, }; -use ra_db::SourceRootId; +use ra_db::{CrateId}; use crate::{ SourceFileItems, SourceItemId, DefId, HirFileId, - FnScopes, + FnScopes, Module, db::HirDatabase, nameres::{ItemMap, Resolver}, }; @@ -41,15 +41,23 @@ pub(super) fn file_item( } } -pub(super) fn item_map(db: &impl HirDatabase, source_root: SourceRootId) -> Arc { +pub(super) fn item_map(db: &impl HirDatabase, crate_id: CrateId) -> Arc { let start = Instant::now(); - let module_tree = db.module_tree(source_root); + let module_tree = db.module_tree(crate_id); let input = module_tree .modules() - .map(|id| (id, db.lower_module_module(source_root, id))) + .map(|module_id| { + ( + module_id, + db.lower_module_module(Module { + krate: crate_id, + module_id, + }), + ) + }) .collect::>(); - let resolver = Resolver::new(db, &input, source_root, module_tree); + let resolver = Resolver::new(db, &input, crate_id); let res = resolver.resolve(); let elapsed = start.elapsed(); log::info!("item_map: {:?}", elapsed); -- cgit v1.2.3 From ec7ed054e06cb2e23fd3911932766b32014c8fa1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 15:28:50 +0300 Subject: Functions use new id scheme --- crates/ra_hir/src/query_definitions.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/query_definitions.rs') diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index a8ed887b3..cf8c7e435 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -10,14 +10,14 @@ use ra_syntax::{ use ra_db::{CrateId}; use crate::{ - SourceFileItems, SourceItemId, DefId, HirFileId, - FnScopes, Module, + SourceFileItems, SourceItemId, HirFileId, + Function, FnScopes, Module, db::HirDatabase, nameres::{ItemMap, Resolver}, }; -pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc { - let body = db.body_hir(def_id); +pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc { + let body = db.body_hir(func); let res = FnScopes::new(body); Arc::new(res) } -- cgit v1.2.3