mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
implement feature flags
This commit is contained in:
parent
4dd5afb7fe
commit
69bbe79c50
11 changed files with 150 additions and 36 deletions
|
@ -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<usize>) -> AnalysisHost {
|
||||
AnalysisHost { db: db::RootDatabase::new(lru_capcity) }
|
||||
pub fn new(lru_capcity: Option<usize>, 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<String> {
|
||||
self.with_db(|db| status::status(&*db))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue