diff options
author | Igor Aleksanov <[email protected]> | 2020-08-07 12:25:55 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-08-07 12:25:55 +0100 |
commit | 90857ff8b08d73945598bac12a841559e86402b1 (patch) | |
tree | 8e98c8d7a1b50d55dbbbf788cda94b11eb3e3395 /crates/rust-analyzer/src | |
parent | c463d217a1e001abe6a812f309d93527e28a70c6 (diff) |
Add an AnalysisConfig structure and use it to configure diagnostics run
Diffstat (limited to 'crates/rust-analyzer/src')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 12 | ||||
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 70b4512d0..2c1db9546 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -7,11 +7,11 @@ | |||
7 | //! configure the server itself, feature flags are passed into analysis, and | 7 | //! configure the server itself, feature flags are passed into analysis, and |
8 | //! tweak things like automatic insertion of `()` in completions. | 8 | //! tweak things like automatic insertion of `()` in completions. |
9 | 9 | ||
10 | use std::{ffi::OsString, path::PathBuf}; | 10 | use std::{collections::HashSet, ffi::OsString, path::PathBuf}; |
11 | 11 | ||
12 | use flycheck::FlycheckConfig; | 12 | use flycheck::FlycheckConfig; |
13 | use lsp_types::ClientCapabilities; | 13 | use lsp_types::ClientCapabilities; |
14 | use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; | 14 | use ra_ide::{AnalysisConfig, AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; |
15 | use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; | 15 | use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; |
16 | use serde::Deserialize; | 16 | use serde::Deserialize; |
17 | use vfs::AbsPathBuf; | 17 | use vfs::AbsPathBuf; |
@@ -45,6 +45,8 @@ pub struct Config { | |||
45 | pub with_sysroot: bool, | 45 | pub with_sysroot: bool, |
46 | pub linked_projects: Vec<LinkedProject>, | 46 | pub linked_projects: Vec<LinkedProject>, |
47 | pub root_path: AbsPathBuf, | 47 | pub root_path: AbsPathBuf, |
48 | |||
49 | pub analysis: AnalysisConfig, | ||
48 | } | 50 | } |
49 | 51 | ||
50 | #[derive(Debug, Clone, Eq, PartialEq)] | 52 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -176,6 +178,8 @@ impl Config { | |||
176 | hover: HoverConfig::default(), | 178 | hover: HoverConfig::default(), |
177 | linked_projects: Vec::new(), | 179 | linked_projects: Vec::new(), |
178 | root_path, | 180 | root_path, |
181 | |||
182 | analysis: AnalysisConfig::default(), | ||
179 | } | 183 | } |
180 | } | 184 | } |
181 | 185 | ||
@@ -293,6 +297,8 @@ impl Config { | |||
293 | goto_type_def: data.hoverActions_enable && data.hoverActions_gotoTypeDef, | 297 | goto_type_def: data.hoverActions_enable && data.hoverActions_gotoTypeDef, |
294 | }; | 298 | }; |
295 | 299 | ||
300 | self.analysis = AnalysisConfig { disabled_diagnostics: data.analysis_disabledDiagnostics }; | ||
301 | |||
296 | log::info!("Config::update() = {:#?}", self); | 302 | log::info!("Config::update() = {:#?}", self); |
297 | } | 303 | } |
298 | 304 | ||
@@ -444,5 +450,7 @@ config_data! { | |||
444 | rustfmt_overrideCommand: Option<Vec<String>> = None, | 450 | rustfmt_overrideCommand: Option<Vec<String>> = None, |
445 | 451 | ||
446 | withSysroot: bool = true, | 452 | withSysroot: bool = true, |
453 | |||
454 | analysis_disabledDiagnostics: HashSet<String> = HashSet::new(), | ||
447 | } | 455 | } |
448 | } | 456 | } |
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 0e592ac1b..46cb7ebe2 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -108,7 +108,7 @@ impl GlobalState { | |||
108 | Handle { handle, receiver } | 108 | Handle { handle, receiver } |
109 | }; | 109 | }; |
110 | 110 | ||
111 | let analysis_host = AnalysisHost::new(config.lru_capacity); | 111 | let analysis_host = AnalysisHost::with_config(config.lru_capacity, config.analysis.clone()); |
112 | let (flycheck_sender, flycheck_receiver) = unbounded(); | 112 | let (flycheck_sender, flycheck_receiver) = unbounded(); |
113 | GlobalState { | 113 | GlobalState { |
114 | sender, | 114 | sender, |