UnpackedSourceMap

Swift
public struct UnpackedSourceMap: Hashable, Sendable

A source map that supports efficient mapping queries.

This bundles together a SourceMap and a cache of its unpacked mapping segments.


Topics

Initializers

init(SourceMap)

Unpack a new source map and cache the segments.

Declaration
Swift
public init(_ sourceMap: SourceMap) throws

Methods

func map(line: Int, column: Int, invalidSourcePos: SourceMap.SourcePos?) -> SourceMap.Segment?

Map a location in the generated code to its source.

All name indices are guaranteed valid at time of call: any out of range are replaced with nil before being returned. All source indices are either valid at time of call or as requested via the invalidSourcePos parameter.

Declaration
Swift
public func map(
    line: Int, column: Int, invalidSourcePos: SourceMap.SourcePos? = nil
) -> SourceMap.Segment?
Parameters
line

0-based index of the line in the generated code file.

column

0-based index of the column in rowIndex.

invalidSourcePos

Value to substitute for any decoded SourceMap.SourcePos that is invalid, ie. refers to a source that is out of range. Default nil.

Return Value

The mapping segment, or nil if there is no mapping for the row.

Properties

var segments: [[SourceMap.Segment]]

The expanded mapping data from sourceMap

Declaration
Swift
public let segments: [[SourceMap.Segment]]

var segmentsDescription: String

A formatted multi-line string describing the mapping segments.

Declaration
Swift
public var segmentsDescription: String { get }

var sourceMap: SourceMap

The base source map

Declaration
Swift
public let sourceMap: SourceMap