Struct hime_redist::text::Text
source · pub struct Text<'a> { /* private fields */ }
Expand description
Represents the input of parser with some metadata for line endings All line numbers and column numbers are 1-based. Indices in the content are 0-based.
Implementations§
source§impl<'a> Text<'a>
impl<'a> Text<'a>
sourcepub fn into_static(self) -> Text<'static>
pub fn into_static(self) -> Text<'static>
Transforms into an owned static version of the data
sourcepub fn from_string(content: String) -> Text<'static>
pub fn from_string(content: String) -> Text<'static>
Initializes this text
sourcepub fn get_line_count(&self) -> usize
pub fn get_line_count(&self) -> usize
Gets the number of lines
sourcepub fn is_end(&self, index: usize) -> bool
pub fn is_end(&self, index: usize) -> bool
Gets whether the specified index is after the end of the text represented by this object
sourcepub fn at(&self, index: usize) -> char
pub fn at(&self, index: usize) -> char
Gets the character at the specified index
Panics
Panic when index is at or beyond the end of the content
sourcepub fn get_value(&self, index: usize, length: usize) -> &str
pub fn get_value(&self, index: usize, length: usize) -> &str
Gets the substring beginning at the given index with the given length
sourcepub fn get_value_for(&self, span: TextSpan) -> &str
pub fn get_value_for(&self, span: TextSpan) -> &str
Get the substring corresponding to the specified span
sourcepub fn get_value_at(&self, position: TextPosition, length: usize) -> &str
pub fn get_value_at(&self, position: TextPosition, length: usize) -> &str
Get the substring corresponding to the text at the specified position and the given length
sourcepub fn get_index_at(&self, position: TextPosition) -> usize
pub fn get_index_at(&self, position: TextPosition) -> usize
Gets the index within the content of the specified position
sourcepub fn get_line_index(&self, line: usize) -> usize
pub fn get_line_index(&self, line: usize) -> usize
Gets the starting index of the i-th line
sourcepub fn get_line_length(&self, line: usize) -> usize
pub fn get_line_length(&self, line: usize) -> usize
Gets the length of the i-th line
sourcepub fn get_line_content(&self, line: usize) -> &str
pub fn get_line_content(&self, line: usize) -> &str
Gets the string content of the i-th line
sourcepub fn get_position_at(&self, index: usize) -> TextPosition
pub fn get_position_at(&self, index: usize) -> TextPosition
Gets the position at the given index
sourcepub fn get_position_for(
&self,
position: TextPosition,
length: usize
) -> TextPosition
pub fn get_position_for( &self, position: TextPosition, length: usize ) -> TextPosition
Gets the position for a starting position and a length
sourcepub fn get_context_at(&self, position: TextPosition) -> TextContext<'_>
pub fn get_context_at(&self, position: TextPosition) -> TextContext<'_>
Gets the context description for the current text at the specified position
sourcepub fn get_context_for(
&self,
position: TextPosition,
length: usize
) -> TextContext<'_>
pub fn get_context_for( &self, position: TextPosition, length: usize ) -> TextContext<'_>
Gets the context description for the current text at the specified position
sourcepub fn get_context_of(&self, span: TextSpan) -> TextContext<'_>
pub fn get_context_of(&self, span: TextSpan) -> TextContext<'_>
Gets the context description for the current text at the specified span
sourcepub fn iter_utf16_from(&self, from: usize) -> Utf16Iter<'_> ⓘ
pub fn iter_utf16_from(&self, from: usize) -> Utf16Iter<'_> ⓘ
Gets an iterator over the UTF-16 codepoints starting at a location