mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +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
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::fix::Fix;
|
||||
use crate::edit::Edit;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -27,7 +27,7 @@ pub struct Diagnostic {
|
|||
pub kind: DiagnosticKind,
|
||||
pub location: Location,
|
||||
pub end_location: Location,
|
||||
pub fix: Option<Fix>,
|
||||
pub fix: Option<Edit>,
|
||||
pub parent: Option<Location>,
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,12 @@ impl Diagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn amend(&mut self, fix: Fix) -> &mut Self {
|
||||
pub fn amend(&mut self, fix: Edit) -> &mut Self {
|
||||
self.fix = Some(fix);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn try_amend(&mut self, func: impl FnOnce() -> Result<Fix>) -> &mut Self {
|
||||
pub fn try_amend(&mut self, func: impl FnOnce() -> Result<Edit>) -> &mut Self {
|
||||
match func() {
|
||||
Ok(fix) => self.fix = Some(fix),
|
||||
Err(err) => error!("Failed to create fix: {}", err),
|
||||
|
|
|
@ -4,13 +4,16 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Fix {
|
||||
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 Fix {
|
||||
impl Edit {
|
||||
pub const fn deletion(start: Location, end: Location) -> Self {
|
||||
Self {
|
||||
content: String::new(),
|
|
@ -1,7 +1,7 @@
|
|||
pub use diagnostic::{Diagnostic, DiagnosticKind};
|
||||
pub use fix::Fix;
|
||||
pub use edit::Edit;
|
||||
pub use violation::{AlwaysAutofixableViolation, AutofixKind, Violation};
|
||||
|
||||
mod diagnostic;
|
||||
mod fix;
|
||||
mod edit;
|
||||
mod violation;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue