Rename setter methods on Diagnostic (#3738)

This commit is contained in:
Charlie Marsh 2023-03-26 10:28:30 -04:00 committed by GitHub
parent 5c7898124f
commit a66481ed28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
123 changed files with 225 additions and 221 deletions

View file

@ -42,21 +42,22 @@ impl Diagnostic {
}
}
pub fn amend(&mut self, fix: Edit) -> &mut Self {
/// Set the [`Edit`] used to fix the diagnostic.
pub fn set_fix(&mut self, fix: Edit) {
self.fix = Some(fix);
self
}
pub fn try_amend(&mut self, func: impl FnOnce() -> Result<Edit>) -> &mut Self {
/// Set the [`Edit`] used to fix the diagnostic, if the provided function returns `Ok`.
/// Otherwise, log the error.
pub fn try_set_fix(&mut self, func: impl FnOnce() -> Result<Edit>) {
match func() {
Ok(fix) => self.fix = Some(fix),
Err(err) => error!("Failed to create fix: {}", err),
}
self
}
pub fn parent(&mut self, parent: Location) -> &mut Self {
/// Set the location of the diagnostic's parent node.
pub fn set_parent(&mut self, parent: Location) {
self.parent = Some(parent);
self
}
}