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 not end the current line.
Callers that want the indent change to take effect on the next line must
call end_line() after this.
Sourcepub fn decrement_indent(&mut self)
pub fn decrement_indent(&mut self)
Inserts an indent end token to the stream. This will not end the current line.
Callers that want the indent change to take effect on the next line must
call end_line() after this.
Sourcepub fn fit_or_split_start(
&mut self,
fit_start: Rc<String>,
fit_delimiter: Rc<String>,
split_end_line: bool,
)
pub fn fit_or_split_start( &mut self, fit_start: Rc<String>, fit_delimiter: Rc<String>, split_end_line: bool, )
Start a fit or split block.
Sourcepub fn potential_split(&mut self)
pub fn potential_split(&mut self)
Insert a potential split in the middle of a fit or split block.
Sourcepub fn fit_or_split_end(
&mut self,
fit_end: Rc<String>,
split_end: Rc<String>,
split_end_line: bool,
)
pub fn fit_or_split_end( &mut self, fit_end: Rc<String>, split_end: Rc<String>, split_end_line: bool, )
End a fit or split block.
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_ast_token_as(&mut self, token: &Token, kind: SyntaxKind)
pub fn push_ast_token_as(&mut self, token: &Token, kind: SyntaxKind)
Pushes an AST token into the stream as another SyntaxKind.
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_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.
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 tokens 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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more