Represents a line and character position, such as the position of the cursor.

Position objects are immutable. Use the {@link Position.with with} or {@link Position.translate translate} methods to derive new positions from an existing position.

Constructor

new(line:Int, character:Int)

Parameters:

line

A zero-based line value.

character

A zero-based character value.

Variables

read onlycharacter:Int

The zero-based character value.

read onlyline:Int

The zero-based line value.

Methods

compareTo(other:Position):Int

Compare this to other.

Parameters:

other

A position.

Returns:

A number smaller than zero if this position is before the given position, a number greater than zero if this position is after the given position, or zero when this and the given position are equal.

isAfter(other:Position):Bool

Check if this position is after other.

Parameters:

other

A position.

Returns:

true if position is on a greater line or on the same line on a greater character.

isAfterOrEqual(other:Position):Bool

Check if this position is after or equal to other.

Parameters:

other

A position.

Returns:

true if position is on a greater line or on the same line on a greater or equal character.

isBefore(other:Position):Bool

Check if this position is before other.

Parameters:

other

A position.

Returns:

true if position is on a smaller line or on the same line on a smaller character.

isBeforeOrEqual(other:Position):Bool

Check if this position is before or equal to other.

Parameters:

other

A position.

Returns:

true if position is on a smaller line or on the same line on a smaller or equal character.

isEqual(other:Position):Bool

Check if this position is equal to other.

Parameters:

other

A position.

Returns:

true if the line and character of the given position are equal to the line and character of this position.

translate(?lineDelta:Int, ?characterDelta:Int):Position

translate(change:{lineDelta:Null<Int>, characterDelta:Null<Int>}):Position

Create a new position relative to this position.

Parameters:

lineDelta

Delta value for the line value, default is 0.

characterDelta

Delta value for the character value, default is 0.

Returns:

A position which line and character is the sum of the current line and character and the corresponding deltas.

with(?line:Int, ?character:Int):Position

with(change:{line:Null<Int>, character:Null<Int>}):Position

Create a new position derived from this position.

@link Position.line existing value} @link Position.character existing value}

Parameters:

line

Value that should be used as line value, default is the {

character

Value that should be used as character value, default is the {

Returns:

A position where line and character are replaced by the given values.