Struct biome_formatter::FormatState
source · pub struct FormatState<Context> {
pub printed_tokens: PrintedTokens,
/* private fields */
}
Expand description
This structure stores the state that is relevant for the formatting of the whole document.
This structure is different from crate::Formatter in that the formatting infrastructure creates a new crate::Formatter for every crate::write! call, whereas this structure stays alive for the whole process of formatting a root with crate::format!.
Fields§
§printed_tokens: PrintedTokens
Implementations§
source§impl<Context> FormatState<Context>
impl<Context> FormatState<Context>
sourcepub fn new(context: Context) -> Self
pub fn new(context: Context) -> Self
Creates a new state with the given language specific context
pub fn into_context(self) -> Context
sourcepub fn context_mut(&mut self) -> &mut Context
pub fn context_mut(&mut self) -> &mut Context
Returns a mutable reference to the context
sourcepub fn group_id(&self, debug_name: &'static str) -> GroupId
pub fn group_id(&self, debug_name: &'static str) -> GroupId
Creates a new group id that is unique to this document. The passed debug name is used in the std::fmt::Debug of the document if this is a debug build. The name is unused for production builds and has no meaning on the equality of two group ids.
sourcepub fn track_token<L: Language>(&mut self, token: &SyntaxToken<L>)
pub fn track_token<L: Language>(&mut self, token: &SyntaxToken<L>)
Tracks the given token as formatted
sourcepub fn set_token_tracking_disabled(&mut self, enabled: bool)
pub fn set_token_tracking_disabled(&mut self, enabled: bool)
Disables or enables token tracking for a portion of the code.
It can be useful to disable the token tracking when it is necessary to re-format a node with different parameters.
sourcepub fn is_token_tracking_disabled(&self) -> bool
pub fn is_token_tracking_disabled(&self) -> bool
Returns true
if token tracking is currently disabled.
sourcepub fn assert_formatted_all_tokens<L: Language>(&self, root: &SyntaxNode<L>)
pub fn assert_formatted_all_tokens<L: Language>(&self, root: &SyntaxNode<L>)
Asserts in debug builds that all tokens have been printed.