pub struct TokenStream<T: Token>(/* private fields */);
Expand description
Implementations§
Source§impl TokenStream<PreToken>
impl TokenStream<PreToken>
Sourcepub fn blank_line(&mut self)
pub fn blank_line(&mut self)
Inserts a blank line token to the stream if the stream does not already
end with a blank line. This will replace any Trivia::BlankLine
tokens with PreToken::BlankLine
.
Sourcepub fn end_line(&mut self)
pub fn end_line(&mut self)
Inserts an end of line token to the stream if the stream does not already end with an end of line token.
This will also trim any trailing PreToken::WordEnd
tokens.
Sourcepub fn end_word(&mut self)
pub fn end_word(&mut self)
Inserts a word end token to the stream if the stream does not already end with a word end token.
Sourcepub fn increment_indent(&mut self)
pub fn increment_indent(&mut self)
Inserts an indent start token to the stream. This will also end the current line.
Sourcepub fn decrement_indent(&mut self)
pub fn decrement_indent(&mut self)
Inserts an indent end token to the stream. This will also end the current line.
Sourcepub fn allow_blank_lines(&mut self)
pub fn allow_blank_lines(&mut self)
Inserts a trivial blank lines “always allowed” context change.
Sourcepub fn ignore_trailing_blank_lines(&mut self)
pub fn ignore_trailing_blank_lines(&mut self)
Inserts a trivial blank lines “not allowed after comments” context change.
Sourcepub fn push_ast_token(&mut self, token: &Token)
pub fn push_ast_token(&mut self, token: &Token)
Pushes an AST token into the stream.
This will also push any preceding or inline trivia into the stream. Any token may have preceding or inline trivia, unless that token is itself trivia (i.e. trivia cannot have trivia).
§Panics
This will panic if the provided token is trivia.
Sourcepub fn push_literal_in_place_of_token(
&mut self,
token: &Token,
replacement: String,
)
pub fn push_literal_in_place_of_token( &mut self, token: &Token, replacement: String, )
Pushes a literal string into the stream in place of an AST token.
This will insert any trivia that would have been inserted with the AST token.
§Panics
This will panic if the provided token is trivia.
Sourcepub fn push_literal(&mut self, value: String, kind: SyntaxKind)
pub fn push_literal(&mut self, value: String, kind: SyntaxKind)
Pushes a literal string into the stream.
This will not insert any trivia.
Sourcepub fn last_literal_kind(&self) -> Option<SyntaxKind>
pub fn last_literal_kind(&self) -> Option<SyntaxKind>
Returns the kind of the last literal token in the stream.
Source§impl<T: Token> TokenStream<T>
impl<T: Token> TokenStream<T>
Sourcepub fn trim_while<F: Fn(&T) -> bool>(&mut self, predicate: F)
pub fn trim_while<F: Fn(&T) -> bool>(&mut self, predicate: F)
Removes any number of token
s at the end of the stream.
Trait Implementations§
Source§impl<T: Clone + Token> Clone for TokenStream<T>
impl<T: Clone + Token> Clone for TokenStream<T>
Source§fn clone(&self) -> TokenStream<T>
fn clone(&self) -> TokenStream<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more