diff options
author | Igor Aleksanov <[email protected]> | 2020-08-18 11:32:29 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-08-18 11:32:29 +0100 |
commit | b56cfcca10994ec2bf1878f222afdb375459f8d3 (patch) | |
tree | c23565cfeb56d8ffcac7f56ca35e22f10b19c210 /crates/rust-analyzer/src | |
parent | c26c911ec1e6c2ad1dcb7d155a6a1d528839ad1a (diff) |
Make disabled diagnostics an argument of corresponding function
Diffstat (limited to 'crates/rust-analyzer/src')
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_bench.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 12 |
5 files changed, 21 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index 0f614f9e0..43f0196af 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs | |||
@@ -71,7 +71,7 @@ impl BenchCmd { | |||
71 | match &self.what { | 71 | match &self.what { |
72 | BenchWhat::Highlight { .. } => { | 72 | BenchWhat::Highlight { .. } => { |
73 | let res = do_work(&mut host, file_id, |analysis| { | 73 | let res = do_work(&mut host, file_id, |analysis| { |
74 | analysis.diagnostics(file_id, true).unwrap(); | 74 | analysis.diagnostics(file_id, true, None).unwrap(); |
75 | analysis.highlight_as_html(file_id, false).unwrap() | 75 | analysis.highlight_as_html(file_id, false).unwrap() |
76 | }); | 76 | }); |
77 | if verbosity.is_verbose() { | 77 | if verbosity.is_verbose() { |
diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index 3371c4fd3..31eb7ff3f 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs | |||
@@ -47,7 +47,7 @@ pub fn diagnostics( | |||
47 | String::from("unknown") | 47 | String::from("unknown") |
48 | }; | 48 | }; |
49 | println!("processing crate: {}, module: {}", crate_name, _vfs.file_path(file_id)); | 49 | println!("processing crate: {}, module: {}", crate_name, _vfs.file_path(file_id)); |
50 | for diagnostic in analysis.diagnostics(file_id, true).unwrap() { | 50 | for diagnostic in analysis.diagnostics(file_id, true, None).unwrap() { |
51 | if matches!(diagnostic.severity, Severity::Error) { | 51 | if matches!(diagnostic.severity, Severity::Error) { |
52 | found_error = true; | 52 | found_error = true; |
53 | } | 53 | } |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 949824479..4e3ab05b2 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -363,6 +363,14 @@ impl Config { | |||
363 | self.client_caps.status_notification = get_bool("statusNotification"); | 363 | self.client_caps.status_notification = get_bool("statusNotification"); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | |||
367 | pub fn disabled_diagnostics(&self) -> Option<HashSet<String>> { | ||
368 | if self.analysis.disabled_diagnostics.is_empty() { | ||
369 | None | ||
370 | } else { | ||
371 | Some(self.analysis.disabled_diagnostics.clone()) | ||
372 | } | ||
373 | } | ||
366 | } | 374 | } |
367 | 375 | ||
368 | #[derive(Deserialize)] | 376 | #[derive(Deserialize)] |
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 8fa31f59c..212f98a30 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::with_config(config.lru_capacity, config.analysis.clone()); | 111 | let analysis_host = AnalysisHost::new(config.lru_capacity); |
112 | let (flycheck_sender, flycheck_receiver) = unbounded(); | 112 | let (flycheck_sender, flycheck_receiver) = unbounded(); |
113 | GlobalState { | 113 | GlobalState { |
114 | sender, | 114 | sender, |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 74f73655a..067f5ff66 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -770,7 +770,11 @@ fn handle_fixes( | |||
770 | None => {} | 770 | None => {} |
771 | }; | 771 | }; |
772 | 772 | ||
773 | let diagnostics = snap.analysis.diagnostics(file_id, snap.config.experimental_diagnostics)?; | 773 | let diagnostics = snap.analysis.diagnostics( |
774 | file_id, | ||
775 | snap.config.experimental_diagnostics, | ||
776 | snap.config.disabled_diagnostics(), | ||
777 | )?; | ||
774 | 778 | ||
775 | for fix in diagnostics | 779 | for fix in diagnostics |
776 | .into_iter() | 780 | .into_iter() |
@@ -1044,7 +1048,11 @@ pub(crate) fn publish_diagnostics( | |||
1044 | let line_index = snap.analysis.file_line_index(file_id)?; | 1048 | let line_index = snap.analysis.file_line_index(file_id)?; |
1045 | let diagnostics: Vec<Diagnostic> = snap | 1049 | let diagnostics: Vec<Diagnostic> = snap |
1046 | .analysis | 1050 | .analysis |
1047 | .diagnostics(file_id, snap.config.experimental_diagnostics)? | 1051 | .diagnostics( |
1052 | file_id, | ||
1053 | snap.config.experimental_diagnostics, | ||
1054 | snap.config.disabled_diagnostics(), | ||
1055 | )? | ||
1048 | .into_iter() | 1056 | .into_iter() |
1049 | .map(|d| Diagnostic { | 1057 | .map(|d| Diagnostic { |
1050 | range: to_proto::range(&line_index, d.range), | 1058 | range: to_proto::range(&line_index, d.range), |