aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r--crates/ra_analysis/src/imp.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 03d17de0d..843f28d05 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -10,7 +10,7 @@ use ra_syntax::{
10 SyntaxKind::*, 10 SyntaxKind::*,
11 SyntaxNodeRef, TextRange, TextUnit, 11 SyntaxNodeRef, TextRange, TextUnit,
12}; 12};
13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase, SourceFileQuery}; 13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase};
14use rayon::prelude::*; 14use rayon::prelude::*;
15use rustc_hash::FxHashSet; 15use rustc_hash::FxHashSet;
16use salsa::{Database, ParallelDatabase}; 16use salsa::{Database, ParallelDatabase};
@@ -43,6 +43,7 @@ impl AnalysisHostImpl {
43 } 43 }
44 pub fn apply_change(&mut self, change: AnalysisChange) { 44 pub fn apply_change(&mut self, change: AnalysisChange) {
45 log::info!("apply_change {:?}", change); 45 log::info!("apply_change {:?}", change);
46 self.gc_syntax_trees();
46 47
47 for (file_id, text) in change.files_changed { 48 for (file_id, text) in change.files_changed {
48 self.db 49 self.db
@@ -115,6 +116,21 @@ impl AnalysisHostImpl {
115 .set((), Arc::new(crate_graph)) 116 .set((), Arc::new(crate_graph))
116 } 117 }
117 } 118 }
119
120 fn gc_syntax_trees(&mut self) {
121 self.db
122 .query(ra_db::SourceFileQuery)
123 .sweep(salsa::SweepStrategy::default().discard_values());
124 self.db
125 .query(hir::db::FnSyntaxQuery)
126 .sweep(salsa::SweepStrategy::default().discard_values());
127 self.db
128 .query(hir::db::SourceFileItemsQuery)
129 .sweep(salsa::SweepStrategy::default().discard_values());
130 self.db
131 .query(hir::db::FileItemQuery)
132 .sweep(salsa::SweepStrategy::default().discard_values());
133 }
118} 134}
119 135
120pub(crate) struct AnalysisImpl { 136pub(crate) struct AnalysisImpl {
@@ -160,9 +176,6 @@ impl AnalysisImpl {
160 .filter_map(|it| it.ok()) 176 .filter_map(|it| it.ok())
161 .collect() 177 .collect()
162 }; 178 };
163 self.db
164 .query(SourceFileQuery)
165 .sweep(salsa::SweepStrategy::default().discard_values());
166 Ok(query.search(&buf)) 179 Ok(query.search(&buf))
167 } 180 }
168 /// This returns `Vec` because a module may be included from several places. We 181 /// This returns `Vec` because a module may be included from several places. We