Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Position

Hierarchy

  • Position

Index

Constructors

constructor

  • new Position(line: number, character: number): Position
  • Constructs a Position from a line and character.

    Parameters

    • line: number

      A zero-based line value.

    • character: number

      A zero-based character value.

    Returns Position

Properties

Readonly character

character: number

Zero-based character on the line.

Readonly line

line: number

Zero-based line number.

Methods

compareTo

  • Compare this to other.

    Parameters

    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.

isAfter

  • Check if this position is after other.

    Parameters

    Returns boolean

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

isAfterOrEqual

  • isAfterOrEqual(other: Position): boolean
  • Check if this position is after or equal to other.

    Parameters

    Returns boolean

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

isBefore

  • Check if this position is before other.

    Parameters

    Returns boolean

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

isBeforeOrEqual

  • isBeforeOrEqual(other: Position): boolean
  • Check if this position is before or equal to other.

    Parameters

    Returns boolean

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

isEqual

  • Check if this position is equal to other.

    Parameters

    Returns boolean

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

translate

  • translate(lineDelta?: undefined | number, characterDelta?: undefined | number): Position
  • translate(change: { characterDelta?: undefined | number; lineDelta?: undefined | number }): Position
  • Create a new position relative to this position.

    Parameters

    • Optional lineDelta: undefined | number

      Delta value for the line value, default is 0.

    • Optional characterDelta: undefined | number

      Delta 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.

  • Derived a new position relative to this position.

    Parameters

    • change: { characterDelta?: undefined | number; lineDelta?: undefined | number }

      An object that describes a delta to this position.

      • Optional characterDelta?: undefined | number
      • Optional lineDelta?: undefined | number

    Returns Position

    A position that reflects the given delta. Will return this position if the change is not changing anything.

with

  • with(line?: undefined | number, character?: undefined | number): Position
  • with(change: { character?: undefined | number; line?: undefined | number }): Position
  • Create a new position derived from this position.

    Parameters

    • Optional line: undefined | number

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

    • Optional character: undefined | number

      Value 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.

  • Derived a new position from this position.

    Parameters

    • change: { character?: undefined | number; line?: undefined | number }

      An object that describes a change to this position.

      • Optional character?: undefined | number
      • Optional line?: undefined | number

    Returns Position

    A position that reflects the given change. Will return this position if the change is not changing anything.

Generated using TypeDoc