pub struct DocSourceMap { /* private fields */ }Expand description
An exact byte-span map from decoded documentation to the string literal.
The map is stored as runs rather than one span per decoded byte: a docstring is overwhelmingly literal text whose spans advance one source byte at a time, so the common case is a single run. Size matters because a whole file’s maps live in the semantic model, which salsa caches and compares for backdating.
Implementations§
Source§impl DocSourceMap
impl DocSourceMap
Sourcepub fn source_range(&self, range: TextRange) -> Option<TextRange>
pub fn source_range(&self, range: TextRange) -> Option<TextRange>
Map a decoded UTF-8 byte range to its enclosing absolute source range.
Returns None for an out-of-bounds range.
Sourcepub fn decoded_offset(&self, offset: TextSize) -> Option<TextSize>
pub fn decoded_offset(&self, offset: TextSize) -> Option<TextSize>
Map an absolute Julia source offset into the decoded documentation.
A cursor anywhere inside an escape maps to the first decoded byte that
escape produced. Bytes removed by triple-string dedenting or a line
continuation have no decoded position and return None.