pub struct LintFix {
pub edit_type: EditType,
pub anchor: Box<dyn Segment>,
pub edit: Option<Vec<Box<dyn Segment>>>,
pub source: Vec<Box<dyn Segment>>,
}
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: Box<dyn Segment>
§edit: Option<Vec<Box<dyn Segment>>>
§source: Vec<Box<dyn Segment>>
Implementations§
source§impl LintFix
impl LintFix
pub fn create_before( anchor: Box<dyn Segment>, edit_segments: Vec<Box<dyn Segment>> ) -> Self
pub fn create_after( anchor: Box<dyn Segment>, edit_segments: Vec<Box<dyn Segment>>, source: Option<Vec<Box<dyn Segment>>> ) -> Self
pub fn replace( anchor_segment: Box<dyn Segment>, edit_segments: Vec<Box<dyn Segment>>, source: Option<Vec<Box<dyn Segment>>> ) -> Self
pub fn delete(anchor_segment: Box<dyn Segment>) -> 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 !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