Make disabled diagnostics an argument of corresponding function

This commit is contained in:
Igor Aleksanov 2020-08-18 13:32:29 +03:00
parent c26c911ec1
commit b56cfcca10
7 changed files with 43 additions and 39 deletions

View file

@ -71,7 +71,7 @@ impl BenchCmd {
match &self.what {
BenchWhat::Highlight { .. } => {
let res = do_work(&mut host, file_id, |analysis| {
analysis.diagnostics(file_id, true).unwrap();
analysis.diagnostics(file_id, true, None).unwrap();
analysis.highlight_as_html(file_id, false).unwrap()
});
if verbosity.is_verbose() {

View file

@ -47,7 +47,7 @@ pub fn diagnostics(
String::from("unknown")
};
println!("processing crate: {}, module: {}", crate_name, _vfs.file_path(file_id));
for diagnostic in analysis.diagnostics(file_id, true).unwrap() {
for diagnostic in analysis.diagnostics(file_id, true, None).unwrap() {
if matches!(diagnostic.severity, Severity::Error) {
found_error = true;
}

View file

@ -363,6 +363,14 @@ impl Config {
self.client_caps.status_notification = get_bool("statusNotification");
}
}
pub fn disabled_diagnostics(&self) -> Option<HashSet<String>> {
if self.analysis.disabled_diagnostics.is_empty() {
None
} else {
Some(self.analysis.disabled_diagnostics.clone())
}
}
}
#[derive(Deserialize)]

View file

@ -108,7 +108,7 @@ impl GlobalState {
Handle { handle, receiver }
};
let analysis_host = AnalysisHost::with_config(config.lru_capacity, config.analysis.clone());
let analysis_host = AnalysisHost::new(config.lru_capacity);
let (flycheck_sender, flycheck_receiver) = unbounded();
GlobalState {
sender,

View file

@ -770,7 +770,11 @@ fn handle_fixes(
None => {}
};
let diagnostics = snap.analysis.diagnostics(file_id, snap.config.experimental_diagnostics)?;
let diagnostics = snap.analysis.diagnostics(
file_id,
snap.config.experimental_diagnostics,
snap.config.disabled_diagnostics(),
)?;
for fix in diagnostics
.into_iter()
@ -1044,7 +1048,11 @@ pub(crate) fn publish_diagnostics(
let line_index = snap.analysis.file_line_index(file_id)?;
let diagnostics: Vec<Diagnostic> = snap
.analysis
.diagnostics(file_id, snap.config.experimental_diagnostics)?
.diagnostics(
file_id,
snap.config.experimental_diagnostics,
snap.config.disabled_diagnostics(),
)?
.into_iter()
.map(|d| Diagnostic {
range: to_proto::range(&line_index, d.range),