From ae9530addc4c5e9bbfd5c0287d3c3adb2de95e40 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 28 Dec 2018 14:34:00 +0100 Subject: Add HIR for impl blocks Since we need to be able to go from def to containing impl block, as well as the other direction, and to find all impls for a certain type, a design similar to the one for modules, where we collect all impls for the whole crate and keep them in an arena, seemed fitting. The ImplBlock type, which provides the public interface, then consists only of an Arc to the arena containing all impls, and the index into it. --- crates/ra_hir/src/db.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/db.rs') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 73a4cdc5c..6d5235ba4 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -4,7 +4,7 @@ use ra_syntax::{SyntaxNode, SourceFileNode}; use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; use crate::{ - DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId, + Crate, DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId, SourceFileItems, SourceItemId, query_definitions, FnScopes, @@ -13,6 +13,7 @@ use crate::{ nameres::{ItemMap, InputModuleItems}}, ty::{InferenceResult, Ty}, adt::{StructData, EnumData}, + impl_block::CrateImplBlocks, }; salsa::query_group! { @@ -87,6 +88,11 @@ pub trait HirDatabase: SyntaxDatabase type ModuleTreeQuery; use fn crate::module::imp::module_tree; } + + fn impls_in_crate(krate: Crate) -> Cancelable> { + type ImplsInCrateQuery; + use fn crate::impl_block::impls_in_crate; + } } } -- cgit v1.2.3 From 443ddb73c395a311b4ddff3bd8267a0eb7079216 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 4 Jan 2019 19:29:53 +0100 Subject: Do impl collection per module, not per crate --- crates/ra_hir/src/db.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/db.rs') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 6d5235ba4..a045bbb12 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -4,7 +4,7 @@ use ra_syntax::{SyntaxNode, SourceFileNode}; use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; use crate::{ - Crate, DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId, + DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId, SourceFileItems, SourceItemId, query_definitions, FnScopes, @@ -13,7 +13,7 @@ use crate::{ nameres::{ItemMap, InputModuleItems}}, ty::{InferenceResult, Ty}, adt::{StructData, EnumData}, - impl_block::CrateImplBlocks, + impl_block::ModuleImplBlocks, }; salsa::query_group! { @@ -89,9 +89,9 @@ pub trait HirDatabase: SyntaxDatabase use fn crate::module::imp::module_tree; } - fn impls_in_crate(krate: Crate) -> Cancelable> { + fn impls_in_module(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable> { type ImplsInCrateQuery; - use fn crate::impl_block::impls_in_crate; + use fn crate::impl_block::impls_in_module; } } -- cgit v1.2.3 From e6aeabf96f9cf339c81f3e79502d477269d141ed Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 4 Jan 2019 19:52:07 +0100 Subject: Rename ImplsInCrateQuery as well --- crates/ra_hir/src/db.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir/src/db.rs') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index a045bbb12..58296fc6f 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -90,7 +90,7 @@ pub trait HirDatabase: SyntaxDatabase } fn impls_in_module(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable> { - type ImplsInCrateQuery; + type ImplsInModuleQuery; use fn crate::impl_block::impls_in_module; } } -- cgit v1.2.3