From e231277ab2f1ebb3040457e89b92540e599dbb3e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 26 Mar 2019 14:13:17 +0300 Subject: make macro parsing a query --- crates/ra_hir/src/db.rs | 5 ++++- crates/ra_hir/src/ids.rs | 6 +++--- crates/ra_hir/src/lib.rs | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 6eb916149..492814cbb 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -4,7 +4,7 @@ use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; use ra_db::{SourceDatabase, salsa}; use crate::{ - HirFileId, SourceFileItems, SourceItemId, Crate, Module, HirInterner, + HirFileId, MacroDefId, SourceFileItems, SourceItemId, Crate, Module, HirInterner, Function, FnSignature, ExprScopes, TypeAlias, Struct, Enum, StructField, Const, ConstSignature, Static, @@ -19,6 +19,9 @@ use crate::{ #[salsa::query_group(DefDatabaseStorage)] pub trait DefDatabase: SourceDatabase + AsRef { + #[salsa::invoke(crate::ids::macro_def_query)] + fn macro_def(&self, macro_id: MacroDefId) -> Option>; + #[salsa::invoke(HirFileId::hir_parse)] fn hir_parse(&self, file_id: HirFileId) -> TreeArc; diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index cf0566308..bac7b9e46 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -101,7 +101,7 @@ fn parse_macro(db: &impl DefDatabase, macro_call_id: MacroCallId) -> Option for HirFileId { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub(crate) enum MacroDefId { +pub enum MacroDefId { MacroByExample { source_item_id: SourceItemId }, } -fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option> { +pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option> { let syntax_node = match id { MacroDefId::MacroByExample { source_item_id } => db.file_item(source_item_id), }; diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 974ebd831..87bc8009d 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -53,7 +53,7 @@ use crate::{ pub use self::{ path::{Path, PathKind}, name::Name, - ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner}, + ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc, HirInterner}, nameres::{PerNs, Namespace}, ty::{Ty, ApplicationTy, TypeCtor, Substs, display::HirDisplay}, impl_block::{ImplBlock, ImplItem}, -- cgit v1.2.3