diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-22 13:17:21 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-22 13:17:21 +0100 |
commit | 0a612fad026df7c270226822e239f8d3137cf31c (patch) | |
tree | e14c62250a13f39860965b15d4e3d7e48d022d67 /crates/ra_ide_api/src/lib.rs | |
parent | 2d0931b9ba7aabdc634c799b32957cc6f057e875 (diff) | |
parent | 69bbe79c5037eb3cd00744593d1836e45a6f56e1 (diff) |
Merge #1715
1715: Feature flags r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/lib.rs')
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 16 |
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; | |||
14 | pub mod mock_analysis; | 14 | pub mod mock_analysis; |
15 | mod symbol_index; | 15 | mod symbol_index; |
16 | mod change; | 16 | mod change; |
17 | mod feature_flags; | ||
17 | 18 | ||
18 | mod status; | 19 | mod status; |
19 | mod completion; | 20 | mod 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 | ||
248 | impl Default for AnalysisHost { | 250 | impl 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 | ||
254 | impl AnalysisHost { | 256 | impl 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)) |