lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.generator.Position Class Reference

A position in a document, including line and column. More...

Inherits Comparable< Position >.

Public Member Functions

int compareTo (Position o)
 Compare two positions according to their order of appearance in a document (first according to line, then according to column).
boolean equals (Object obj)
int getOneBasedColumn ()
 Return the one-based column number described by this Position.
int getOneBasedLine ()
 Return the one-based line number described by this Position.
int getZeroBasedColumn ()
 Return the zero-based column number described by this Position.
int getZeroBasedLine ()
 Return the zero-based line number described by this Position.
int hashCode ()
Position minus (Position other)
 Return the difference of this and another Position.
Position plus (Position other)
 Return the sum of this and another Position.
Position plus (String text)
 Return the Position that equals the displacement of ((text whose displacement equals this) concatenated with text).
String toString ()

Static Public Member Functions

static Position displacementOf (String text)
 Return the Position that equals the displacement caused by text, assuming that text starts in column 0.
static Position fromOffset (int offset, String content)
 Return the Position that describes the same location in content as offset.
static Position fromOneBased (int line, int column)
 Return the Position that describes the given one-based line and column numbers.
static Position fromString (String s)
 Return the Position represented by s.
static Position fromZeroBased (int line, int column)
 Return the Position that describes the given zero-based line and column numbers.
static String removeNamedCapturingGroups (Pattern regex)
 Remove the names from the named capturing groups that appear in regex.

Static Public Attributes

static final Position ORIGIN = Position.fromZeroBased(0, 0)
static final Pattern PATTERN = Pattern.compile("\\‍((?<line>[0-9]+), (?<column>[0-9]+)\\‍)")

Detailed Description

A position in a document, including line and column.

This position may be relative to some position other than the origin.

Author
Peter Donovan

Member Function Documentation

◆ compareTo()

int org.lflang.generator.Position.compareTo ( Position o)

Compare two positions according to their order of appearance in a document (first according to line, then according to column).

◆ displacementOf()

Position org.lflang.generator.Position.displacementOf ( String text)
static

Return the Position that equals the displacement caused by text, assuming that text starts in column 0.

Parameters
textan arbitrary string
Returns
the Position that equals the displacement caused by text

◆ equals()

boolean org.lflang.generator.Position.equals ( Object obj)

◆ fromOffset()

Position org.lflang.generator.Position.fromOffset ( int offset,
String content )
static

Return the Position that describes the same location in content as offset.

Parameters
offseta location, expressed as an offset from the beginning of content
contentthe content of a document
Returns
the Position that describes the same location in content as offset

◆ fromOneBased()

Position org.lflang.generator.Position.fromOneBased ( int line,
int column )
static

Return the Position that describes the given one-based line and column numbers.

Parameters
linethe one-based line number
columnthe one-based column number
Returns
a Position describing the position described by line and column.

◆ fromString()

Position org.lflang.generator.Position.fromString ( String s)
static

Return the Position represented by s.

Parameters
sa String that represents a Position, formatted like the output of Position.toString.
Returns
the Position represented by s

◆ fromZeroBased()

Position org.lflang.generator.Position.fromZeroBased ( int line,
int column )
static

Return the Position that describes the given zero-based line and column numbers.

Parameters
linethe zero-based line number
columnthe zero-based column number
Returns
a Position describing the position described by line and column.

◆ getOneBasedColumn()

int org.lflang.generator.Position.getOneBasedColumn ( )

Return the one-based column number described by this Position.

Returns
the one-based column number described by this Position

◆ getOneBasedLine()

int org.lflang.generator.Position.getOneBasedLine ( )

Return the one-based line number described by this Position.

Returns
the one-based line number described by this Position

◆ getZeroBasedColumn()

int org.lflang.generator.Position.getZeroBasedColumn ( )

Return the zero-based column number described by this Position.

Returns
the zero-based column number described by this Position

◆ getZeroBasedLine()

int org.lflang.generator.Position.getZeroBasedLine ( )

Return the zero-based line number described by this Position.

Returns
the zero-based line number described by this Position

◆ hashCode()

int org.lflang.generator.Position.hashCode ( )

◆ minus()

Position org.lflang.generator.Position.minus ( Position other)

Return the difference of this and another Position.

The result has meaning because Positions are relative.

Parameters
otheranother Position
Returns
the difference of this and other

◆ plus() [1/2]

Position org.lflang.generator.Position.plus ( Position other)

Return the sum of this and another Position.

The result has meaning because Positions are relative.

Parameters
otheranother Position
Returns
the sum of this and other

◆ plus() [2/2]

Position org.lflang.generator.Position.plus ( String text)

Return the Position that equals the displacement of ((text whose displacement equals this) concatenated with text).

Note that this is not necessarily equal to (this + displacementOf(text)).

Parameters
textan arbitrary string
Returns
the Position that equals the displacement caused by text

◆ removeNamedCapturingGroups()

String org.lflang.generator.Position.removeNamedCapturingGroups ( Pattern regex)
static

Remove the names from the named capturing groups that appear in regex.

Parameters
regexan arbitrary regular expression
Returns
a string representation of regex with the names removed from the named capturing groups

◆ toString()

String org.lflang.generator.Position.toString ( )

Member Data Documentation

◆ ORIGIN

final Position org.lflang.generator.Position.ORIGIN = Position.fromZeroBased(0, 0)
static

◆ PATTERN

final Pattern org.lflang.generator.Position.PATTERN = Pattern.compile("\\‍((?<line>[0-9]+), (?<column>[0-9]+)\\‍)")
static

The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/generator/Position.java