Skip to main content

Class: Position

libs/common/types/Position.Position

Constructors

constructor

new Position(line, character)

Parameters

NameTypeDescription
linenumberA zero-based line value.
characternumberA zero-based character value.

Defined in

libs/common/types/Position.ts:18

Properties

character

Readonly character: number

The zero-based character value.

Defined in

libs/common/types/Position.ts:12


line

Readonly line: number

The zero-based line value.

Defined in

libs/common/types/Position.ts:7

Methods

compareTo

compareTo(other): number

Compare this to other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

number

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.

Defined in

libs/common/types/Position.ts:98


isAfter

isAfter(other): boolean

Check if this position is after other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

boolean

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

Defined in

libs/common/types/Position.ts:58


isAfterOrEqual

isAfterOrEqual(other): boolean

Check if this position is after or equal to other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

boolean

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

Defined in

libs/common/types/Position.ts:86


isBefore

isBefore(other): boolean

Check if this position is before other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

boolean

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

Defined in

libs/common/types/Position.ts:41


isBeforeOrEqual

isBeforeOrEqual(other): boolean

Check if this position is before or equal to other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

boolean

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

Defined in

libs/common/types/Position.ts:75


isEqual

isEqual(other): boolean

Check if this position is equal to other.

Parameters

NameTypeDescription
otherPositionA position.

Returns

boolean

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

Defined in

libs/common/types/Position.ts:30


toEmptyRange

toEmptyRange(): Range

Create a new empty range from this position.

Returns

Range

A Range

Defined in

libs/common/types/Position.ts:138


translate

translate(lineDelta?, characterDelta?): Position

Create a new position relative to this position.

Parameters

NameTypeDescription
lineDelta?numberDelta value for the line value, default is 0.
characterDelta?numberDelta value for the character value, default is 0.

Returns

Position

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

Defined in

libs/common/types/Position.ts:127


with

with(line?, character?): Position

Create a new position derived from this position.

Parameters

NameTypeDescription
line?numberValue that should be used as line value, default is the existing value
character?numberValue that should be used as character value, default is the existing value

Returns

Position

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

Defined in

libs/common/types/Position.ts:115