pub struct SourceMapBuilder { /* private fields */ }Expand description
Builder for incrementally constructing source maps.
§Example
use oak_source_map::SourceMapBuilder;
let mut builder = SourceMapBuilder::new();
// Add a source file
let source_idx = builder.add_source("input.ts");
// Add mappings
builder.add_mapping(0, 0, Some(source_idx), Some(0), Some(0), None);
builder.add_mapping(0, 10, Some(source_idx), Some(0), Some(10), None);
// Build the final source map
let source_map = builder.build();Implementations§
Source§impl SourceMapBuilder
impl SourceMapBuilder
Sourcepub fn source_root(self, root: impl Into<String>) -> Self
pub fn source_root(self, root: impl Into<String>) -> Self
Sets the source root.
Sourcepub fn add_source(&mut self, source: impl Into<String>) -> u32
pub fn add_source(&mut self, source: impl Into<String>) -> u32
Adds a source file and returns its index.
Sourcepub fn set_source_content(&mut self, index: u32, content: impl Into<String>)
pub fn set_source_content(&mut self, index: u32, content: impl Into<String>)
Sets the content for a source file.
Sourcepub fn add_mapping(
&mut self,
generated_line: u32,
generated_column: u32,
source_index: Option<u32>,
original_line: Option<u32>,
original_column: Option<u32>,
name_index: Option<u32>,
)
pub fn add_mapping( &mut self, generated_line: u32, generated_column: u32, source_index: Option<u32>, original_line: Option<u32>, original_column: Option<u32>, name_index: Option<u32>, )
Adds a mapping.
All line and column values are 0-indexed.
Trait Implementations§
Source§impl Debug for SourceMapBuilder
impl Debug for SourceMapBuilder
Source§impl Default for SourceMapBuilder
impl Default for SourceMapBuilder
Source§fn default() -> SourceMapBuilder
fn default() -> SourceMapBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SourceMapBuilder
impl RefUnwindSafe for SourceMapBuilder
impl Send for SourceMapBuilder
impl Sync for SourceMapBuilder
impl Unpin for SourceMapBuilder
impl UnsafeUnpin for SourceMapBuilder
impl UnwindSafe for SourceMapBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more