Range

open class Range(source)

A range represents an ordered pair of two positions. It is guaranteed that start}.isBeforeOrEqual({@link Range.end end)

Range objects are immutable. Use the with, intersection}, or {@link Range.union union methods to derive new ranges from an existing range.

Online Documentation

Inheritors

Constructors

Link copied to clipboard
constructor(start: Position, end: Position)

Create a new range from two positions. If start is not before or equal to end, the values will be swapped.

constructor(startLine: Int, startCharacter: Int, endLine: Int, endCharacter: Int)

Create a new range from number coordinates. It is a shorter equivalent of using new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))

Types

Link copied to clipboard
interface WithChange

Properties

Link copied to clipboard

The end position. It is after or equal to start.

Link copied to clipboard

true if start and end are equal.

Link copied to clipboard

true if start.line and end.line are equal.

Link copied to clipboard

The start position. It is before or equal to end.

Functions

Link copied to clipboard
fun contains(positionOrRange: JsAny): Boolean

Check if a position or a range is contained in this range.

Link copied to clipboard
fun intersection(range: Range): Range?

Intersect range with this range and returns a new range or undefined if the ranges have no overlap.

Link copied to clipboard
fun isEqual(other: Range): Boolean

Check if other equals this range.

Link copied to clipboard
fun union(other: Range): Range

Compute the union of other with this range.

Link copied to clipboard
fun with(start: Position = definedExternally, end: Position = definedExternally): Range

Derived a new range from this range.