SourceRange
classin packageklyn.code.ast
public class SourceRange extends Object
└ SourceRange

Represents a half-open or inclusive line/column source range in a file.

Line and column numbers are zero-based (0 is the first line and first column).

import klyn.code.ast

range = SourceRange(2, 0, 10, 4)
assert range.containsLine(5)
assert range.lineSpan == 9
Properties
Modifier and Type Member Description
public readonly property endColumn
endColumn as Long
Zero-based ending column index.
public readonly property endLine
endLine as Long
Zero-based inclusive ending line index.
public readonly property lineSpan
lineSpan as Long
Total number of lines spanned by this range (endLine - startLine + 1).
public readonly property startColumn
startColumn as Long
Zero-based starting column index.
public readonly property startLine
startLine as Long
Zero-based starting line index.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public SourceRange
SourceRange( startLine as Long = 0, startColumn as Long = 0, endLine as Long = 0, endColumn as Long = 0 )
Constructs a SourceRange from zero-based start/end line and column coordinates.
Methods
Modifier and Type Member Description
public containsLine
containsLine(line as Long) as Boolean
Checks whether a zero-based line index falls within [startLine, endLine].
public withEnd
withEnd(newEndLine as Long, newEndColumn as Long = 0) as SourceRange
Returns a new SourceRange with an updated endLine and endColumn.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml