pub struct LintFix {
pub edit_type: EditType,
pub anchor: ErasedSegment,
pub edit: Option<Vec<ErasedSegment>>,
pub source: Vec<ErasedSegment>,
}
Expand description
A class to hold a potential fix to a linting violation.
Args:
edit_type (:obj:`str`): One of `create_before`, `create_after`,
`replace`, `delete` to indicate the kind of fix this represents.
anchor (:obj:`BaseSegment`): A segment which represents
the *position* that this fix should be applied at. For deletions
it represents the segment to delete, for creations it implies
the position to create at (with the existing element at this
position to be moved after the edit), for a replace
it
implies the segment to be replaced.
edit (iterable of :obj:BaseSegment
, optional): For replace
and
create
fixes, this holds the iterable of segments to create
or replace at the given anchor
point.
source (iterable of :obj:BaseSegment
, optional): For replace
and
create
fixes, this holds iterable of segments that provided
code. IMPORTANT: The linter uses this to prevent copying
material from templated areas.
Fields§
§edit_type: EditType
§anchor: ErasedSegment
§edit: Option<Vec<ErasedSegment>>
§source: Vec<ErasedSegment>
Implementations§
source§impl LintFix
impl LintFix
pub fn create_before( anchor: ErasedSegment, edit_segments: Vec<ErasedSegment> ) -> Self
pub fn create_after( anchor: ErasedSegment, edit_segments: Vec<ErasedSegment>, source: Option<Vec<ErasedSegment>> ) -> Self
pub fn replace( anchor_segment: ErasedSegment, edit_segments: Vec<ErasedSegment>, source: Option<Vec<ErasedSegment>> ) -> Self
pub fn delete(anchor_segment: ErasedSegment) -> Self
sourcepub fn is_just_source_edit(&self) -> bool
pub fn is_just_source_edit(&self) -> bool
Return whether this a valid source only edit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LintFix
impl !RefUnwindSafe for LintFix
impl Send for LintFix
impl Sync for LintFix
impl Unpin for LintFix
impl !UnwindSafe for LintFix
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more