From 6c63a59425e256ce46d058807b64149297231982 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 4 May 2019 11:53:44 +0300 Subject: eagarly clean astd maps --- crates/ra_hir/src/db.rs | 2 +- crates/ra_hir/src/source_id.rs | 2 +- crates/ra_ide_api/src/change.rs | 6 ++++++ crates/ra_syntax/src/grammar.ron | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 8af0a3176..3ac3c79a3 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -60,7 +60,7 @@ pub trait DefDatabase: SourceDatabase { #[salsa::invoke(crate::source_id::AstIdMap::ast_id_map_query)] fn ast_id_map(&self, file_id: HirFileId) -> Arc; - #[salsa::invoke(crate::source_id::AstIdMap::file_item_query)] + #[salsa::invoke(crate::source_id::AstIdMap::ast_id_to_node_query)] fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> TreeArc; #[salsa::invoke(RawItems::raw_items_query)] diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs index 0a8fb6d32..a2bc9a799 100644 --- a/crates/ra_hir/src/source_id.rs +++ b/crates/ra_hir/src/source_id.rs @@ -92,7 +92,7 @@ impl AstIdMap { Arc::new(AstIdMap::from_source_file(&source_file)) } - pub(crate) fn file_item_query( + pub(crate) fn ast_id_to_node_query( db: &impl DefDatabase, file_id: HirFileId, ast_id: ErasedFileAstId, diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 5bfdbe7e9..16b9ef3d5 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs @@ -186,6 +186,7 @@ impl RootDatabase { if let Some(crate_graph) = change.crate_graph { self.set_crate_graph(Arc::new(crate_graph)) } + self.collect_after_change() } fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) { @@ -228,4 +229,9 @@ impl RootDatabase { self.query(hir::db::RawItemsWithSourceMapQuery).sweep(sweep); self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep); } + + pub(crate) fn collect_after_change(&mut self) { + let sweep = SweepStrategy::default().discard_everything().sweep_all_revisions(); + self.query(hir::db::AstIdToNodeQuery).sweep(sweep) + } } diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 011ef0616..cae5d8774 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -674,7 +674,7 @@ Grammar( "LifetimeArg": (), "MacroItems": ( - traits: [ "ModuleItemOwner", "FnDefOwner" ], + traits: [ "ModuleItemOwner", "FnDefOwner" ], ), "MacroStmts" : ( -- cgit v1.2.3