pub struct GeneratedOffsetLookup<'a> { /* private fields */ }Expand description
Converts generated UTF-8 byte offsets into source-map generated positions.
V8 coverage ranges are often reported as byte offsets in generated code, while source maps use generated line and UTF-16 column pairs. This helper builds a reusable line index for one generated asset and converts offsets before forwarding them to a source map lookup.
Implementations§
Source§impl<'a> GeneratedOffsetLookup<'a>
impl<'a> GeneratedOffsetLookup<'a>
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of generated lines tracked by this lookup.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total byte length of the generated source.
Sourcepub fn byte_offset_to_position(
&self,
byte_offset: u32,
) -> Option<GeneratedLocation>
pub fn byte_offset_to_position( &self, byte_offset: u32, ) -> Option<GeneratedLocation>
Convert a generated UTF-8 byte offset to a 0-based line and UTF-16 column.
Returns None when the offset is out of bounds, does not fit in u32,
or points into the middle of a UTF-8 code point. Offsets that point at a
line terminator resolve to the end column of that line. Offsets after a
line terminator resolve to column 0 of the next line.
Sourcepub fn original_position_for_offset<M>(
&self,
source_map: &M,
byte_offset: u32,
) -> Option<OriginalLocation>where
M: OriginalPositionLookup + ?Sized,
pub fn original_position_for_offset<M>(
&self,
source_map: &M,
byte_offset: u32,
) -> Option<OriginalLocation>where
M: OriginalPositionLookup + ?Sized,
Look up the original source position for a generated byte offset.
Sourcepub fn byte_offsets_to_positions(
&self,
byte_offsets: &[u32],
) -> Option<Vec<GeneratedLocation>>
pub fn byte_offsets_to_positions( &self, byte_offsets: &[u32], ) -> Option<Vec<GeneratedLocation>>
Convert multiple generated byte offsets to generated positions.
Returns None if any offset is invalid.
Sourcepub fn original_positions_for_offsets<M>(
&self,
source_map: &M,
byte_offsets: &[u32],
) -> Vec<Option<OriginalLocation>>where
M: OriginalPositionLookup + ?Sized,
pub fn original_positions_for_offsets<M>(
&self,
source_map: &M,
byte_offsets: &[u32],
) -> Vec<Option<OriginalLocation>>where
M: OriginalPositionLookup + ?Sized,
Look up original source positions for multiple generated byte offsets.
Trait Implementations§
Source§impl<'a> Clone for GeneratedOffsetLookup<'a>
impl<'a> Clone for GeneratedOffsetLookup<'a>
Source§fn clone(&self) -> GeneratedOffsetLookup<'a>
fn clone(&self) -> GeneratedOffsetLookup<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more