pub struct TransformSourceMapBuilder { /* private fields */ }
Expand description
Builder for creating a source map.
Implementations§
source§impl TransformSourceMapBuilder
impl TransformSourceMapBuilder
pub fn with_offset(offset: TextSize) -> Self
sourcepub fn with_source(source: String) -> Self
pub fn with_source(source: String) -> Self
Creates a new builder for a document with the given source.
sourcepub fn push_source_text(&mut self, text: &str)
pub fn push_source_text(&mut self, text: &str)
Appends text
to the source text of the original document.
sourcepub fn add_deleted_range(&mut self, source_range: TextRange)
pub fn add_deleted_range(&mut self, source_range: TextRange)
Adds a new mapping for a deleted character range.
sourcepub fn extend_trimmed_node_range(
&mut self,
original_range: TextRange,
extended_range: TextRange
)
pub fn extend_trimmed_node_range( &mut self, original_range: TextRange, extended_range: TextRange )
Adds a mapping to widen a nodes trimmed range.
The formatter uses the trimmed range when formatting a node in verbatim either because the node
failed to format because of a syntax error or because it’s formatting is suppressed with a biome-ignore format:
comment.
This method adds a mapping to widen a nodes trimmed range to enclose another range instead. This is
e.g. useful when removing parentheses around expressions where (/* comment */ a /* comment */)
because
the trimmed range of a
should now enclose the full range including the (
and )
tokens to ensure
that the parentheses are retained when printing that node in verbatim style.
sourcepub fn finish(self) -> TransformSourceMap
pub fn finish(self) -> TransformSourceMap
Creates a source map that performs single position lookups in O(log(n))
.