aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-22 12:44:16 +0100
committerAleksey Kladov <[email protected]>2019-08-22 13:07:31 +0100
commit69bbe79c5037eb3cd00744593d1836e45a6f56e1 (patch)
treefc48327d9d70b320c60e6c9fc19fdc5bdbff88f9 /crates/ra_ide_api/src/lib.rs
parent4dd5afb7fe2eb20748ade9141e74b04f5dd2f922 (diff)
implement feature flags
Diffstat (limited to 'crates/ra_ide_api/src/lib.rs')
-rw-r--r--crates/ra_ide_api/src/lib.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index fa4ae4379..514dcaf96 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -14,6 +14,7 @@ mod db;
14pub mod mock_analysis; 14pub mod mock_analysis;
15mod symbol_index; 15mod symbol_index;
16mod change; 16mod change;
17mod feature_flags;
17 18
18mod status; 19mod status;
19mod completion; 20mod completion;
@@ -63,6 +64,7 @@ pub use crate::{
63 completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, 64 completion::{CompletionItem, CompletionItemKind, InsertTextFormat},
64 diagnostics::Severity, 65 diagnostics::Severity,
65 display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, 66 display::{file_structure, FunctionSignature, NavigationTarget, StructureNode},
67 feature_flags::FeatureFlags,
66 folding_ranges::{Fold, FoldKind}, 68 folding_ranges::{Fold, FoldKind},
67 hover::HoverResult, 69 hover::HoverResult,
68 inlay_hints::{InlayHint, InlayKind}, 70 inlay_hints::{InlayHint, InlayKind},
@@ -247,13 +249,13 @@ pub struct AnalysisHost {
247 249
248impl Default for AnalysisHost { 250impl Default for AnalysisHost {
249 fn default() -> AnalysisHost { 251 fn default() -> AnalysisHost {
250 AnalysisHost::new(None) 252 AnalysisHost::new(None, FeatureFlags::default())
251 } 253 }
252} 254}
253 255
254impl AnalysisHost { 256impl AnalysisHost {
255 pub fn new(lru_capcity: Option<usize>) -> AnalysisHost { 257 pub fn new(lru_capcity: Option<usize>, feature_flags: FeatureFlags) -> AnalysisHost {
256 AnalysisHost { db: db::RootDatabase::new(lru_capcity) } 258 AnalysisHost { db: db::RootDatabase::new(lru_capcity, feature_flags) }
257 } 259 }
258 /// Returns a snapshot of the current state, which you can query for 260 /// Returns a snapshot of the current state, which you can query for
259 /// semantic information. 261 /// semantic information.
@@ -261,6 +263,10 @@ impl AnalysisHost {
261 Analysis { db: self.db.snapshot() } 263 Analysis { db: self.db.snapshot() }
262 } 264 }
263 265
266 pub fn feature_flags(&self) -> &FeatureFlags {
267 &self.db.feature_flags
268 }
269
264 /// Applies changes to the current state of the world. If there are 270 /// Applies changes to the current state of the world. If there are
265 /// outstanding snapshots, they will be canceled. 271 /// outstanding snapshots, they will be canceled.
266 pub fn apply_change(&mut self, change: AnalysisChange) { 272 pub fn apply_change(&mut self, change: AnalysisChange) {
@@ -319,6 +325,10 @@ impl Analysis {
319 (host.analysis(), file_id) 325 (host.analysis(), file_id)
320 } 326 }
321 327
328 pub fn feature_flags(&self) -> &FeatureFlags {
329 &self.db.feature_flags
330 }
331
322 /// Debug info about the current state of the analysis 332 /// Debug info about the current state of the analysis
323 pub fn status(&self) -> Cancelable<String> { 333 pub fn status(&self) -> Cancelable<String> {
324 self.with_db(|db| status::status(&*db)) 334 self.with_db(|db| status::status(&*db))