Record Class ErrorSource

java.lang.Object
java.lang.Record
org.skriptlang.skript.log.runtime.ErrorSource
Record Components:
syntaxType - A string representing the type of syntax. See SyntaxElement.getSyntaxTypeName().
syntaxName - The name of the syntax emitting the error.
lineNumber - The line number of the syntax emitting the error.
lineText - The raw code of the line.
script - The name of the script in which the line exists.

public record ErrorSource(String syntaxType, String syntaxName, int lineNumber, String lineText, String script) extends Record
A more versatile set of information about the source of an error. Aims to avoid relying specifically on Nodes for information.
  • Constructor Details

    • ErrorSource

      public ErrorSource(String syntaxType, String syntaxName, int lineNumber, String lineText, String script)
      Creates an instance of a ErrorSource record class.
      Parameters:
      syntaxType - the value for the syntaxType record component
      syntaxName - the value for the syntaxName record component
      lineNumber - the value for the lineNumber record component
      lineText - the value for the lineText record component
      script - the value for the script record component
  • Method Details

    • fromNodeAndElement

      @NotNull public static @NotNull ErrorSource fromNodeAndElement(@Nullable @Nullable Node node, @NotNull @NotNull SyntaxElement element)
      Creates an error source using information from a given node and syntax element.
      Parameters:
      node - The node to use for line, line number, and script name.
      element - The element to use for the type and name.
      Returns:
      A new error source.
    • location

      @Contract(" -> new") @NotNull public @NotNull ErrorSource.Location location()
      Returns:
      The code location (line number and script name) of the source of the error. Used for hash maps.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • syntaxType

      public String syntaxType()
      Returns the value of the syntaxType record component.
      Returns:
      the value of the syntaxType record component
    • syntaxName

      public String syntaxName()
      Returns the value of the syntaxName record component.
      Returns:
      the value of the syntaxName record component
    • lineNumber

      public int lineNumber()
      Returns the value of the lineNumber record component.
      Returns:
      the value of the lineNumber record component
    • lineText

      public String lineText()
      Returns the value of the lineText record component.
      Returns:
      the value of the lineText record component
    • script

      public String script()
      Returns the value of the script record component.
      Returns:
      the value of the script record component