mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00
Rename Fix
to Edit
(#3702)
This commit is contained in:
parent
c721eedc37
commit
2083134a96
109 changed files with 394 additions and 404 deletions
44
crates/ruff_diagnostics/src/edit.rs
Normal file
44
crates/ruff_diagnostics/src/edit.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue