pub trait Segment:
Any
+ AsAny
+ DynClone
+ Debug
+ CloneSegment {
Show 46 methods
// Provided methods
fn new(&self, _segments: Vec<ErasedSegment>) -> ErasedSegment { ... }
fn copy(&self, _segments: Vec<ErasedSegment>) -> ErasedSegment { ... }
fn can_start_end_non_code(&self) -> bool { ... }
fn dialect(&self) -> DialectKind { ... }
fn type_name(&self) -> &'static str { ... }
fn get_start_loc(&self) -> (usize, usize) { ... }
fn get_end_loc(&self) -> (usize, usize) { ... }
fn to_serialised(
&self,
code_only: bool,
show_raw: bool,
include_meta: bool,
) -> TupleSerialisedSegment { ... }
fn raw_segments_with_ancestors(
&self,
) -> &OnceCell<Vec<(ErasedSegment, Vec<PathStep>)>> { ... }
fn select_children(
&self,
start_seg: Option<&ErasedSegment>,
stop_seg: Option<&ErasedSegment>,
select_if: Option<fn(_: &ErasedSegment) -> bool>,
loop_while: Option<fn(_: &ErasedSegment) -> bool>,
) -> Vec<ErasedSegment> { ... }
fn is_templated(&self) -> bool { ... }
fn iter_segments(
&self,
expanding: Option<SyntaxSet>,
pass_through: bool,
) -> Vec<ErasedSegment> { ... }
fn code_indices(&self) -> Vec<usize> { ... }
fn get_parent(&self) -> Option<ErasedSegment> { ... }
fn child(&self, seg_types: SyntaxSet) -> Option<ErasedSegment> { ... }
fn children(&self, seg_types: SyntaxSet) -> Vec<ErasedSegment> { ... }
fn iter_patches(&self, templated_file: &TemplatedFile) -> Vec<FixPatch> { ... }
fn descendant_type_set(&self) -> &SyntaxSet { ... }
fn raw(&self) -> Cow<'_, str> { ... }
fn get_raw_upper(&self) -> Option<String> { ... }
fn first_non_whitespace_segment_raw_upper(&self) -> Option<String> { ... }
fn get_type(&self) -> SyntaxKind { ... }
fn is_type(&self, type_: SyntaxKind) -> bool { ... }
fn is_code(&self) -> bool { ... }
fn is_comment(&self) -> bool { ... }
fn is_whitespace(&self) -> bool { ... }
fn is_meta(&self) -> bool { ... }
fn get_default_raw(&self) -> Option<&'static str> { ... }
fn get_position_marker(&self) -> Option<PositionMarker> { ... }
fn set_position_marker(&mut self, position_marker: Option<PositionMarker>) { ... }
fn segments(&self) -> &[ErasedSegment] { ... }
fn set_segments(&mut self, _segments: Vec<ErasedSegment>) { ... }
fn gather_segments(&self) -> Vec<ErasedSegment> { ... }
fn get_matched_length(&self) -> usize { ... }
fn get_can_start_end_non_code(&self) -> bool { ... }
fn get_allow_empty(&self) -> bool { ... }
fn get_file_path(&self) -> Option<String> { ... }
fn get_raw_segments(&self) -> Vec<ErasedSegment> { ... }
fn iter_source_fix_patches(
&self,
templated_file: &TemplatedFile,
) -> Vec<FixPatch> { ... }
fn get_uuid(&self) -> Uuid { ... }
fn get_source_fixes(&self) -> Vec<SourceFix> { ... }
fn edit(
&self,
raw: Option<String>,
source_fixes: Option<Vec<SourceFix>>,
) -> ErasedSegment { ... }
fn compute_anchor_edit_info(
&self,
fixes: &Vec<LintFix>,
) -> AHashMap<Uuid, AnchorEditInfo> { ... }
fn instance_types(&self) -> SyntaxSet { ... }
fn combined_types(&self) -> SyntaxSet { ... }
fn class_types(&self) -> SyntaxSet { ... }
}Provided Methods§
fn new(&self, _segments: Vec<ErasedSegment>) -> ErasedSegment
fn copy(&self, _segments: Vec<ErasedSegment>) -> ErasedSegment
fn can_start_end_non_code(&self) -> bool
fn dialect(&self) -> DialectKind
fn type_name(&self) -> &'static str
fn get_start_loc(&self) -> (usize, usize)
fn get_end_loc(&self) -> (usize, usize)
fn to_serialised( &self, code_only: bool, show_raw: bool, include_meta: bool, ) -> TupleSerialisedSegment
fn raw_segments_with_ancestors( &self, ) -> &OnceCell<Vec<(ErasedSegment, Vec<PathStep>)>>
fn select_children( &self, start_seg: Option<&ErasedSegment>, stop_seg: Option<&ErasedSegment>, select_if: Option<fn(_: &ErasedSegment) -> bool>, loop_while: Option<fn(_: &ErasedSegment) -> bool>, ) -> Vec<ErasedSegment>
fn is_templated(&self) -> bool
fn iter_segments( &self, expanding: Option<SyntaxSet>, pass_through: bool, ) -> Vec<ErasedSegment>
fn code_indices(&self) -> Vec<usize>
fn get_parent(&self) -> Option<ErasedSegment>
fn child(&self, seg_types: SyntaxSet) -> Option<ErasedSegment>
fn children(&self, seg_types: SyntaxSet) -> Vec<ErasedSegment>
fn iter_patches(&self, templated_file: &TemplatedFile) -> Vec<FixPatch>
fn descendant_type_set(&self) -> &SyntaxSet
fn raw(&self) -> Cow<'_, str>
fn get_raw_upper(&self) -> Option<String>
fn first_non_whitespace_segment_raw_upper(&self) -> Option<String>
fn get_type(&self) -> SyntaxKind
fn is_type(&self, type_: SyntaxKind) -> bool
fn is_code(&self) -> bool
fn is_comment(&self) -> bool
fn is_whitespace(&self) -> bool
fn is_meta(&self) -> bool
fn get_default_raw(&self) -> Option<&'static str>
fn get_position_marker(&self) -> Option<PositionMarker>
fn set_position_marker(&mut self, position_marker: Option<PositionMarker>)
fn segments(&self) -> &[ErasedSegment]
fn set_segments(&mut self, _segments: Vec<ErasedSegment>)
fn gather_segments(&self) -> Vec<ErasedSegment>
sourcefn get_matched_length(&self) -> usize
fn get_matched_length(&self) -> usize
Return the length of the segment in characters.
sourcefn get_can_start_end_non_code(&self) -> bool
fn get_can_start_end_non_code(&self) -> bool
Are we able to have non-code at the start or end?
sourcefn get_allow_empty(&self) -> bool
fn get_allow_empty(&self) -> bool
Can we allow it to be empty? Usually used in combination with the can_start_end_non_code.
sourcefn get_file_path(&self) -> Option<String>
fn get_file_path(&self) -> Option<String>
get_file_path returns the file path of the segment if it is a file segment.
sourcefn get_raw_segments(&self) -> Vec<ErasedSegment>
fn get_raw_segments(&self) -> Vec<ErasedSegment>
Iterate raw segments, mostly for searching.
In sqlfluff only implemented for RawSegments and up
sourcefn iter_source_fix_patches(
&self,
templated_file: &TemplatedFile,
) -> Vec<FixPatch>
fn iter_source_fix_patches( &self, templated_file: &TemplatedFile, ) -> Vec<FixPatch>
Yield any source patches as fixes now.
NOTE: This yields source fixes for the segment and any of its
children, so it's important to call it at the right point in
the recursion to avoid yielding duplicates.fn get_uuid(&self) -> Uuid
sourcefn get_source_fixes(&self) -> Vec<SourceFix>
fn get_source_fixes(&self) -> Vec<SourceFix>
Return any source fixes as list.
sourcefn edit(
&self,
raw: Option<String>,
source_fixes: Option<Vec<SourceFix>>,
) -> ErasedSegment
fn edit( &self, raw: Option<String>, source_fixes: Option<Vec<SourceFix>>, ) -> ErasedSegment
Stub.
sourcefn compute_anchor_edit_info(
&self,
fixes: &Vec<LintFix>,
) -> AHashMap<Uuid, AnchorEditInfo>
fn compute_anchor_edit_info( &self, fixes: &Vec<LintFix>, ) -> AHashMap<Uuid, AnchorEditInfo>
Group and count fixes by anchor, return dictionary.