Set the 'source' field for general langserver diagnostics

This commit is contained in:
Tad Hardesty 2019-11-06 22:01:09 -08:00
parent 316ddb286a
commit ac971ee8f5

View file

@ -353,7 +353,7 @@ impl<'a, W: io::ResponseWrite> Engine<'a, W> {
message: error.description().to_owned(),
severity: Some(convert_severity(error.severity())),
range: location_to_range(loc),
source: error.component().name().map(ToOwned::to_owned),
source: component_to_source(error.component()),
related_information,
.. Default::default()
};
@ -368,7 +368,7 @@ impl<'a, W: io::ResponseWrite> Engine<'a, W> {
message: note.description().to_owned(),
severity: Some(langserver::DiagnosticSeverity::Information),
range: location_to_range(note.location()),
source: error.component().name().map(ToOwned::to_owned),
source: component_to_source(error.component()),
.. Default::default()
};
map.entry(self.file_url(note.location().file)?)
@ -491,7 +491,7 @@ impl<'a, W: io::ResponseWrite> Engine<'a, W> {
message: error.description().to_owned(),
severity: Some(convert_severity(error.severity())),
range: location_to_range(loc),
source: error.component().name().map(ToOwned::to_owned),
source: component_to_source(error.component()),
related_information,
.. Default::default()
};
@ -504,7 +504,7 @@ impl<'a, W: io::ResponseWrite> Engine<'a, W> {
message: note.description().to_owned(),
severity: Some(langserver::DiagnosticSeverity::Information),
range: location_to_range(note.location()),
source: error.component().name().map(ToOwned::to_owned),
source: component_to_source(error.component()),
.. Default::default()
};
diagnostics.push(diag);
@ -1720,3 +1720,7 @@ where
}));
write.write(serde_json::to_string(&request).expect("notification bad to_string"))
}
fn component_to_source(component: dm::Component) -> Option<String> {
Some(component.name().unwrap_or("dm-langserver").to_owned())
}