diff options
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 |
2 files changed, 17 insertions, 8 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 | }; |
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,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 | ||
120 | pub(crate) struct AnalysisImpl { | 136 | pub(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 |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ff41fd326..62cf9ab17 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -27,20 +27,16 @@ pub trait HirDatabase: SyntaxDatabase | |||
27 | } | 27 | } |
28 | fn fn_syntax(fn_id: FnId) -> FnDefNode { | 28 | fn fn_syntax(fn_id: FnId) -> FnDefNode { |
29 | type FnSyntaxQuery; | 29 | type FnSyntaxQuery; |
30 | // Don't retain syntax trees in memory | ||
31 | storage dependencies; | ||
32 | use fn query_definitions::fn_syntax; | 30 | use fn query_definitions::fn_syntax; |
33 | } | 31 | } |
34 | 32 | ||
35 | fn file_items(file_id: FileId) -> Arc<SourceFileItems> { | 33 | fn file_items(file_id: FileId) -> Arc<SourceFileItems> { |
36 | type SourceFileItemsQuery; | 34 | type SourceFileItemsQuery; |
37 | storage dependencies; | ||
38 | use fn query_definitions::file_items; | 35 | use fn query_definitions::file_items; |
39 | } | 36 | } |
40 | 37 | ||
41 | fn file_item(source_item_id: SourceItemId) -> SyntaxNode { | 38 | fn file_item(source_item_id: SourceItemId) -> SyntaxNode { |
42 | type FileItemQuery; | 39 | type FileItemQuery; |
43 | storage dependencies; | ||
44 | use fn query_definitions::file_item; | 40 | use fn query_definitions::file_item; |
45 | } | 41 | } |
46 | 42 | ||