Rename Fix to Edit (#3702)

This commit is contained in:
Charlie Marsh 2023-03-24 19:29:14 -04:00 committed by GitHub
parent c721eedc37
commit 2083134a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 394 additions and 404 deletions

View file

@ -0,0 +1,44 @@
use rustpython_parser::ast::Location;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Edit {
/// The replacement content to insert between the start and end locations.
pub content: String,
/// The start location of the edit.
pub location: Location,
/// The end location of the edit.
pub end_location: Location,
}
impl Edit {
pub const fn deletion(start: Location, end: Location) -> Self {
Self {
content: String::new(),
location: start,
end_location: end,
}
}
pub fn replacement(content: String, start: Location, end: Location) -> Self {
debug_assert!(!content.is_empty(), "Prefer `Fix::deletion`");
Self {
content,
location: start,
end_location: end,
}
}
pub fn insertion(content: String, at: Location) -> Self {
debug_assert!(!content.is_empty(), "Insert content is empty");
Self {
content,
location: at,
end_location: at,
}
}
}