Record Class SemanticError

java.lang.Object
java.lang.Record
com.darkcollective.relix.semantic.SemanticError
Record Components:
filePath - the path of the source file; must not be null
line - the 1-based source line (0 = no position)
column - the 1-based source column (0 = no position)
message - a human-readable description of the problem; must not be blank
severity - whether this is an error or a warning

public record SemanticError(String filePath, int line, int column, String message, Severity severity) extends Record
A single diagnostic produced during semantic analysis of a .relix script.

Every error carries the path of the file it originated from together with the line and column of the problematic source construct. Line and column are 1-based; a value of 0 indicates that no meaningful position is available (e.g. for file-level errors such as a missing import file).

Factory methods cover the two common cases:

   SemanticError.error("./api.relix", 12, 5, "Unknown relation 'Foo'");
   SemanticError.warning("./api.relix", 3, 1, "Unused import 'bar'");
 
  • Constructor Details

    • SemanticError

      public SemanticError(String filePath, int line, int column, String message, Severity severity)
      Creates an instance of a SemanticError 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
      message - the value for the message record component
      severity - the value for the severity record component
  • Method Details

    • error

      public static SemanticError error(String filePath, int line, int column, String message)
      Creates an Severity.ERROR-severity diagnostic.
      Parameters:
      filePath - the source file path
      line - 1-based line number (0 = no position)
      column - 1-based column number (0 = no position)
      message - the error description; must not be blank
      Returns:
      a new SemanticError
    • warning

      public static SemanticError warning(String filePath, int line, int column, String message)
      Creates a Severity.WARNING-severity diagnostic.
      Parameters:
      filePath - the source file path
      line - 1-based line number (0 = no position)
      column - 1-based column number (0 = no position)
      message - the warning description; must not be blank
      Returns:
      a new SemanticError
    • toString

      public String toString()
      Returns a human-readable representation in the form <file>:<line>:<col>: <severity>: <message>.
      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
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • severity

      public Severity severity()
      Returns the value of the severity record component.
      Returns:
      the value of the severity record component