pub struct LineIndex { /* private fields */ }Implementations§
Source§impl LineIndex
impl LineIndex
pub fn new(content: String) -> Self
pub fn line_col_to_byte_range(&self, line: usize, column: usize) -> Range<usize>
Sourcepub fn line_col_to_byte_range_with_length(
&self,
line: usize,
column: usize,
length: usize,
) -> Range<usize>
pub fn line_col_to_byte_range_with_length( &self, line: usize, column: usize, length: usize, ) -> Range<usize>
Calculate a proper byte range for replacing text with a specific length This is the correct function to use for LSP fixes
Sourcepub fn whole_line_range(&self, line: usize) -> Range<usize>
pub fn whole_line_range(&self, line: usize) -> Range<usize>
Calculate byte range for entire line replacement (including newline) This is ideal for rules that need to replace complete lines
Sourcepub fn line_text_range(
&self,
line: usize,
start_col: usize,
end_col: usize,
) -> Range<usize>
pub fn line_text_range( &self, line: usize, start_col: usize, end_col: usize, ) -> Range<usize>
Calculate byte range for text within a line (excluding newline) Useful for replacing specific parts of a line
Sourcepub fn line_content_range(&self, line: usize) -> Range<usize>
pub fn line_content_range(&self, line: usize) -> Range<usize>
Calculate byte range from start of line to end of line content (excluding newline) Useful for replacing line content while preserving line structure
Sourcepub fn get_line_start_byte(&self, line_num: usize) -> Option<usize>
pub fn get_line_start_byte(&self, line_num: usize) -> Option<usize>
Get the global start byte offset for a given 1-based line number.
Sourcepub fn is_code_block(&self, line: usize) -> bool
pub fn is_code_block(&self, line: usize) -> bool
Check if the line at the given index is within a code block
Sourcepub fn is_code_fence(&self, line: usize) -> bool
pub fn is_code_fence(&self, line: usize) -> bool
Check if the line is a code fence marker (``` or ~~~)
Sourcepub fn is_tilde_code_block(&self, line: usize) -> bool
pub fn is_tilde_code_block(&self, line: usize) -> bool
Check if the line is a tilde code fence marker (~~~)
Sourcepub fn get_content(&self) -> &str
pub fn get_content(&self) -> &str
Get a reference to the content
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LineIndex
impl RefUnwindSafe for LineIndex
impl Send for LineIndex
impl Sync for LineIndex
impl Unpin for LineIndex
impl UnwindSafe for LineIndex
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
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>
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>
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