Make it opt-in

This commit is contained in:
Jonas Schievink 2021-06-03 16:11:20 +02:00
parent e5a2c6596d
commit 9fdb8f9037
9 changed files with 44 additions and 4 deletions

View file

@ -126,6 +126,9 @@ config_data! {
/// and a blue icon in the `Problems Panel`.
diagnostics_warningsAsInfo: Vec<String> = "[]",
/// Expand attribute macros.
experimental_procAttrMacros: bool = "false",
/// Controls file watching implementation.
files_watcher: String = "\"client\"",
/// These directories will be ignored by rust-analyzer.
@ -546,6 +549,9 @@ impl Config {
let path = self.data.procMacro_server.clone().or_else(|| std::env::current_exe().ok())?;
Some((path, vec!["proc-macro".into()]))
}
pub fn expand_proc_attr_macros(&self) -> bool {
self.data.experimental_procAttrMacros
}
pub fn files(&self) -> FilesConfig {
FilesConfig {
watcher: match self.data.files_watcher.as_str() {

View file

@ -119,12 +119,12 @@ impl GlobalState {
let analysis_host = AnalysisHost::new(config.lru_capacity());
let (flycheck_sender, flycheck_receiver) = unbounded();
GlobalState {
let mut this = GlobalState {
sender,
req_queue: ReqQueue::default(),
task_pool,
loader,
config: Arc::new(config),
config: Arc::new(config.clone()),
analysis_host,
diagnostics: Default::default(),
mem_docs: FxHashMap::default(),
@ -151,7 +151,10 @@ impl GlobalState {
fetch_build_data_queue: OpQueue::default(),
latest_requests: Default::default(),
}
};
// Apply any required database inputs from the config.
this.update_configuration(config);
this
}
pub(crate) fn process_changes(&mut self) -> bool {

View file

@ -2,6 +2,7 @@
use std::{mem, sync::Arc};
use flycheck::{FlycheckConfig, FlycheckHandle};
use hir::db::DefDatabase;
use ide::Change;
use ide_db::base_db::{CrateGraph, SourceRoot, VfsPath};
use project_model::{BuildDataCollector, BuildDataResult, ProcMacroClient, ProjectWorkspace};
@ -47,6 +48,11 @@ impl GlobalState {
} else if self.config.flycheck() != old_config.flycheck() {
self.reload_flycheck();
}
// Apply experimental feature flags.
self.analysis_host
.raw_database_mut()
.set_enable_proc_attr_macros(self.config.expand_proc_attr_macros());
}
pub(crate) fn maybe_refresh(&mut self, changes: &[(AbsPathBuf, ChangeKind)]) {
if !changes.iter().any(|(path, kind)| is_interesting(path, *kind)) {