aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r--crates/ide/src/lib.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index b762c994e..a19a379c6 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -151,16 +151,11 @@ impl<T> RangeInfo<T> {
151#[derive(Debug)] 151#[derive(Debug)]
152pub struct AnalysisHost { 152pub struct AnalysisHost {
153 db: RootDatabase, 153 db: RootDatabase,
154 config: AnalysisConfig,
155} 154}
156 155
157impl AnalysisHost { 156impl AnalysisHost {
158 pub fn new(lru_capacity: Option<usize>) -> Self { 157 pub fn new(lru_capacity: Option<usize>) -> Self {
159 Self::with_config(lru_capacity, AnalysisConfig::default()) 158 AnalysisHost { db: RootDatabase::new(lru_capacity) }
160 }
161
162 pub fn with_config(lru_capacity: Option<usize>, config: AnalysisConfig) -> Self {
163 AnalysisHost { db: RootDatabase::new(lru_capacity), config }
164 } 159 }
165 160
166 pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) { 161 pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) {
@@ -170,7 +165,7 @@ impl AnalysisHost {
170 /// Returns a snapshot of the current state, which you can query for 165 /// Returns a snapshot of the current state, which you can query for
171 /// semantic information. 166 /// semantic information.
172 pub fn analysis(&self) -> Analysis { 167 pub fn analysis(&self) -> Analysis {
173 Analysis { db: self.db.snapshot(), config: self.config.clone() } 168 Analysis { db: self.db.snapshot() }
174 } 169 }
175 170
176 /// Applies changes to the current state of the world. If there are 171 /// Applies changes to the current state of the world. If there are
@@ -214,7 +209,6 @@ impl Default for AnalysisHost {
214#[derive(Debug)] 209#[derive(Debug)]
215pub struct Analysis { 210pub struct Analysis {
216 db: salsa::Snapshot<RootDatabase>, 211 db: salsa::Snapshot<RootDatabase>,
217 config: AnalysisConfig,
218} 212}
219 213
220// As a general design guideline, `Analysis` API are intended to be independent 214// As a general design guideline, `Analysis` API are intended to be independent
@@ -509,8 +503,11 @@ impl Analysis {
509 &self, 503 &self,
510 file_id: FileId, 504 file_id: FileId,
511 enable_experimental: bool, 505 enable_experimental: bool,
506 disabled_diagnostics: Option<HashSet<String>>,
512 ) -> Cancelable<Vec<Diagnostic>> { 507 ) -> Cancelable<Vec<Diagnostic>> {
513 self.with_db(|db| diagnostics::diagnostics(db, file_id, enable_experimental, &self.config)) 508 self.with_db(|db| {
509 diagnostics::diagnostics(db, file_id, enable_experimental, disabled_diagnostics)
510 })
514 } 511 }
515 512
516 /// Returns the edit required to rename reference at the position to the new 513 /// Returns the edit required to rename reference at the position to the new
@@ -539,11 +536,6 @@ impl Analysis {
539 }) 536 })
540 } 537 }
541 538
542 /// Sets the provided config.
543 pub fn set_config(&mut self, config: AnalysisConfig) {
544 self.config = config;
545 }
546
547 /// Performs an operation on that may be Canceled. 539 /// Performs an operation on that may be Canceled.
548 fn with_db<F, T>(&self, f: F) -> Cancelable<T> 540 fn with_db<F, T>(&self, f: F) -> Cancelable<T>
549 where 541 where