diff options
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 03d17de0d..0de0e2645 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 | }; |
13 | use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase, SourceFileQuery}; | 13 | use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase}; |
14 | use rayon::prelude::*; | 14 | use rayon::prelude::*; |
15 | use rustc_hash::FxHashSet; | 15 | use rustc_hash::FxHashSet; |
16 | use salsa::{Database, ParallelDatabase}; | 16 | use 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,25 @@ impl AnalysisHostImpl { | |||
115 | .set((), Arc::new(crate_graph)) | 116 | .set((), Arc::new(crate_graph)) |
116 | } | 117 | } |
117 | } | 118 | } |
119 | |||
120 | #[allow(unused)] | ||
121 | /// Ideally, we should call this function from time to time to collect heavy | ||
122 | /// syntax trees. However, if we actually do that, everything is recomputed | ||
123 | /// for some reason. Needs investigation. | ||
124 | fn gc_syntax_trees(&mut self) { | ||
125 | self.db | ||
126 | .query(ra_db::SourceFileQuery) | ||
127 | .sweep(salsa::SweepStrategy::default().discard_values()); | ||
128 | self.db | ||
129 | .query(hir::db::FnSyntaxQuery) | ||
130 | .sweep(salsa::SweepStrategy::default().discard_values()); | ||
131 | self.db | ||
132 | .query(hir::db::SourceFileItemsQuery) | ||
133 | .sweep(salsa::SweepStrategy::default().discard_values()); | ||
134 | self.db | ||
135 | .query(hir::db::FileItemQuery) | ||
136 | .sweep(salsa::SweepStrategy::default().discard_values()); | ||
137 | } | ||
118 | } | 138 | } |
119 | 139 | ||
120 | pub(crate) struct AnalysisImpl { | 140 | pub(crate) struct AnalysisImpl { |
@@ -160,9 +180,6 @@ impl AnalysisImpl { | |||
160 | .filter_map(|it| it.ok()) | 180 | .filter_map(|it| it.ok()) |
161 | .collect() | 181 | .collect() |
162 | }; | 182 | }; |
163 | self.db | ||
164 | .query(SourceFileQuery) | ||
165 | .sweep(salsa::SweepStrategy::default().discard_values()); | ||
166 | Ok(query.search(&buf)) | 183 | Ok(query.search(&buf)) |
167 | } | 184 | } |
168 | /// This returns `Vec` because a module may be included from several places. We | 185 | /// This returns `Vec` because a module may be included from several places. We |