Segment

Swift
public struct Segment: Hashable, Sendable

extension Segment: CustomStringConvertible

A decoded segment of the source map.

This maps a region from a particular generated line (not explicit in this type) and column range (really just start column) to a source region and optionally a name, or asserts that range is not related to a source.

All indices are 0-based.


Topics

Initializers

init(columns: Range<Int32>, sourcePos: SourcePos?)

Initialize a segment from a RangeRange of columns.

Declaration
Swift
public init(columns: Range<Int32>, sourcePos: SourcePos? = nil)

init(columns: ClosedRange<Int32>, sourcePos: SourcePos?)

Initialize a segment from a ClosedRangeClosedRange of columns.

Declaration
Swift
public init(columns: ClosedRange<Int32>, sourcePos: SourcePos? = nil)

init(firstColumn: Int32, lastColumn: Int32?, sourcePos: SourcePos?)

Initialize a segment from column indices.

Declaration
Swift
public init(
    firstColumn: Int32, lastColumn: Int32? = nil, sourcePos: SourcePos? = nil)

Properties

var columns: ClosedRange<Int32>?

The range of columns covered by this segment, or nil if not known.

Declaration
Swift
public var columns: ClosedRange<Int32>? { get }

var description: String

A short human-readable description of the segment.

Declaration
Swift
public var description: String { get }

var firstColumn: Int32

0-based column in the generated code that starts the segment.

Declaration
Swift
public let firstColumn: Int32

var lastColumn: Int32?

0-based column in the generated code that ends the segment, or nil indicating ‘until either the next segment or the end of the line’.

This field is optional and advisory - it’s not stored in the source map itself, rather calculated (guessed) from the next firstColumn value. Its value is not used in comparisons between two Segments.

Declaration
Swift
public internal(set) var lastColumn: Int32? { get }

var sourcePos: SourcePos?

The original source position associated with the segment, or nil if there is none.

Declaration
Swift
public let sourcePos: SourcePos?