Trait TokenSource

Source
pub trait TokenSource {
    type Kind: SyntaxKind;

    // Required methods
    fn current(&self) -> Self::Kind;
    fn current_range(&self) -> TextRange;
    fn text(&self) -> &str;
    fn has_preceding_line_break(&self) -> bool;
    fn bump(&mut self);
    fn skip_as_trivia(&mut self);
    fn finish(self) -> (Vec<Trivia>, Vec<ParseDiagnostic>);

    // Provided method
    fn position(&self) -> TextSize { ... }
}

Required Associated Types§

Required Methods§

Source

fn current(&self) -> Self::Kind

Returns the kind of the current non-trivia token

Source

fn current_range(&self) -> TextRange

Returns the range of the current non-trivia token

Source

fn text(&self) -> &str

Returns the source text

Source

fn has_preceding_line_break(&self) -> bool

Returns true if the current token is preceded by a line break

Source

fn bump(&mut self)

Source

fn skip_as_trivia(&mut self)

Source

fn finish(self) -> (Vec<Trivia>, Vec<ParseDiagnostic>)

Ends this token source and returns the source text’s trivia

Provided Methods§

Source

fn position(&self) -> TextSize

Returns the byte offset of the current token from the start of the source document

Implementors§