From 69bbe79c5037eb3cd00744593d1836e45a6f56e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 22 Aug 2019 14:44:16 +0300 Subject: implement feature flags --- crates/ra_ide_api/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide_api/src/lib.rs') 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; pub mod mock_analysis; mod symbol_index; mod change; +mod feature_flags; mod status; mod completion; @@ -63,6 +64,7 @@ pub use crate::{ completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, diagnostics::Severity, display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, + feature_flags::FeatureFlags, folding_ranges::{Fold, FoldKind}, hover::HoverResult, inlay_hints::{InlayHint, InlayKind}, @@ -247,13 +249,13 @@ pub struct AnalysisHost { impl Default for AnalysisHost { fn default() -> AnalysisHost { - AnalysisHost::new(None) + AnalysisHost::new(None, FeatureFlags::default()) } } impl AnalysisHost { - pub fn new(lru_capcity: Option) -> AnalysisHost { - AnalysisHost { db: db::RootDatabase::new(lru_capcity) } + pub fn new(lru_capcity: Option, feature_flags: FeatureFlags) -> AnalysisHost { + AnalysisHost { db: db::RootDatabase::new(lru_capcity, feature_flags) } } /// Returns a snapshot of the current state, which you can query for /// semantic information. @@ -261,6 +263,10 @@ impl AnalysisHost { Analysis { db: self.db.snapshot() } } + pub fn feature_flags(&self) -> &FeatureFlags { + &self.db.feature_flags + } + /// Applies changes to the current state of the world. If there are /// outstanding snapshots, they will be canceled. pub fn apply_change(&mut self, change: AnalysisChange) { @@ -319,6 +325,10 @@ impl Analysis { (host.analysis(), file_id) } + pub fn feature_flags(&self) -> &FeatureFlags { + &self.db.feature_flags + } + /// Debug info about the current state of the analysis pub fn status(&self) -> Cancelable { self.with_db(|db| status::status(&*db)) -- cgit v1.2.3