Skip to main content

format_node

Function format_node 

Source
pub fn format_node(node: &SyntaxNode) -> String
Expand description

Format a SOURCE_FILE syntax node in opinionated canonical form.

The bare-node entry for callers that already parsed the CST (typically LSP formatting providers). Output rules are the same as format_source.

Internally runs compute_alignment on node to derive the file-wide column targets. Hot paths that hold a precomputed PostingAlignment (e.g., via crate::ParseResult::alignment) should call format_node_with_alignment instead to skip the per-call walk. Equivalence pinned by format_node_equals_format_node_with_alignment in this file’s tests.