pub struct LineToken {
pub source_tokens: Vec<Token>,
pub token_spans: Vec<Range<usize>>,
pub line_type: LineType,
}Expand description
A line token represents one logical line created from grouped raw tokens.
Line tokens are produced by the line token transformation, which groups raw tokens into semantic line units. Each line token stores:
- The original raw tokens that created it (for location information and AST construction)
- The line type (what kind of line this is)
- Individual token spans (to enable byte-accurate text extraction from token subsets)
By preserving raw tokens and their individual spans, we can later pass them directly to existing AST constructors (using the same unified approach as the the parser), which handles all location tracking and AST node creation automatically.
Note: LineToken does NOT store an aggregate source_span. The AST construction facade will compute bounding boxes from the individual token_spans when needed.
Fields§
§source_tokens: Vec<Token>The original raw tokens that comprise this line
token_spans: Vec<Range<usize>>The byte range in source code for each token Must be the same length as source_tokens
line_type: LineTypeThe type/classification of this line
Implementations§
Source§impl LineToken
impl LineToken
Sourcepub fn source_token_pairs(&self) -> Vec<(Token, Range<usize>)>
pub fn source_token_pairs(&self) -> Vec<(Token, Range<usize>)>
Get source tokens as (Token, Range
This creates owned pairs from the separate source_tokens and token_spans vectors. Used by the AST construction facade to get tokens in the format expected by the token processing utilities.
Note: LineToken stores tokens and spans separately for serialization efficiency. This method creates the paired format needed for location tracking.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LineToken
impl<'de> Deserialize<'de> for LineToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for LineToken
Auto Trait Implementations§
impl Freeze for LineToken
impl RefUnwindSafe for LineToken
impl Send for LineToken
impl Sync for LineToken
impl Unpin for LineToken
impl UnwindSafe for LineToken
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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