Record Class SourceLocation

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.SourceLocation
Record Components:
filePath - the path of the source file; never null
line - 1-based source line (0 = no position available)
column - 1-based source column (0 = no position available)

public record SourceLocation(String filePath, int line, int column) extends Record
The source location of an AST node — file path, 1-based line, and 1-based column of the first character of the construct.

All three components are carried together so that nodes remain fully self-describing after semantic analysis assembles a SemanticModel from multiple files.

UNKNOWN is the sentinel used when a node was constructed programmatically (e.g. in tests) without access to a source position.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SourceLocation
    Sentinel used when no real source location is available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SourceLocation(String filePath, int line, int column)
    Creates an instance of a SourceLocation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the column record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the filePath record component.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the line record component.
    Returns a human-readable filePath:line:column string.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • UNKNOWN

      public static final SourceLocation UNKNOWN
      Sentinel used when no real source location is available.
  • Constructor Details

    • SourceLocation

      public SourceLocation(String filePath, int line, int column)
      Creates an instance of a SourceLocation record class.
      Parameters:
      filePath - the value for the filePath record component
      line - the value for the line record component
      column - the value for the column record component
  • Method Details

    • toString

      public String toString()
      Returns a human-readable filePath:line:column string. When line is 0 the positional part is omitted.
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • filePath

      public String filePath()
      Returns the value of the filePath record component.
      Returns:
      the value of the filePath record component
    • line

      public int line()
      Returns the value of the line record component.
      Returns:
      the value of the line record component
    • column

      public int column()
      Returns the value of the column record component.
      Returns:
      the value of the column record component