Record Class JSError

java.lang.Object
java.lang.Record
com.google.javascript.jscomp.JSError
Record Components:
type - A type of the error.
description - Description of the error.
sourceName - Name of the source
lineno - One-indexed line number of the error location.
charno - Zero-indexed character number of the error location.
length - Length of the error region.
node - Node where the warning occurred.
defaultLevel - The default level, before any of the WarningsGuards are applied.
requirement - Requirement that fails in the case of conformance violations.
All Implemented Interfaces:
Serializable

public record JSError(DiagnosticType type, String description, @Nullable String sourceName, int lineno, int charno, int length, @Nullable Node node, CheckLevel defaultLevel, @Nullable com.google.javascript.jscomp.Requirement requirement) extends Record implements Serializable
Compile error description.
See Also:
  • Constructor Details

    • JSError

      public JSError(DiagnosticType type, String description, @Nullable String sourceName, int lineno, int charno, int length, @Nullable Node node, CheckLevel defaultLevel, @Nullable com.google.javascript.jscomp.Requirement requirement)
      Creates an instance of a JSError record class.
      Parameters:
      type - the value for the type record component
      description - the value for the description record component
      sourceName - the value for the sourceName record component
      lineno - the value for the lineno record component
      charno - the value for the charno record component
      length - the value for the length record component
      node - the value for the node record component
      defaultLevel - the value for the defaultLevel record component
      requirement - the value for the requirement record component
  • Method Details

    • getType

      @InlineMe(replacement="this.type()") public DiagnosticType getType()
    • getDescription

      @InlineMe(replacement="this.description()") public String getDescription()
    • getSourceName

      @InlineMe(replacement="this.sourceName()") public @Nullable String getSourceName()
    • getLineno

      @InlineMe(replacement="this.lineno()") public int getLineno()
    • getCharno

      @InlineMe(replacement="this.charno()") public int getCharno()
    • getLength

      @InlineMe(replacement="this.length()") public int getLength()
    • getNode

      @InlineMe(replacement="this.node()") public @Nullable Node getNode()
    • getDefaultLevel

      @InlineMe(replacement="this.defaultLevel()") public CheckLevel getDefaultLevel()
    • getRequirement

      @InlineMe(replacement="this.requirement()") public @Nullable com.google.javascript.jscomp.Requirement getRequirement()
    • make

      public static JSError make(DiagnosticType type, String... arguments)
      Creates a JSError with no source information
      Parameters:
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments)
      Creates a JSError at a given source location
      Parameters:
      sourceName - The source file name
      lineno - Line number with source file, or -1 if unknown
      charno - Column number within line, or -1 for whole line.
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(Node n, DiagnosticType type, String... arguments)
      Creates a JSError from a file and Node position.
      Parameters:
      n - Determines the line and char position and source file name
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(Node start, Node end, DiagnosticType type, String... arguments)
      Creates a JSError from a file and Node position.
      Parameters:
      start - Determines the line and char position and source file name
      end - Determines the length of the error region
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments)
      Creates a JSError from a requirement, file and Node position.
      Parameters:
      requirement - The conformance requirement that fails
      n - Determines the line and char position and source file name
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • 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
    • format

      public final @Nullable String format(CheckLevel level, MessageFormatter formatter)
      Format a message at the given level.
      Returns:
      the formatted message or null
    • getNodeSourceOffset

      public final int getNodeSourceOffset()
      Returns:
      the offset of the region the Error applies to, or -1 if the offset is unknown.
    • getLineNumber

      public final int getLineNumber()
      Alias for getLineno().
    • 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.
    • type

      public DiagnosticType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • sourceName

      public @Nullable String sourceName()
      Returns the value of the sourceName record component.
      Returns:
      the value of the sourceName record component
    • lineno

      public int lineno()
      Returns the value of the lineno record component.
      Returns:
      the value of the lineno record component
    • charno

      public int charno()
      Returns the value of the charno record component.
      Returns:
      the value of the charno record component
    • length

      public int length()
      Returns the value of the length record component.
      Returns:
      the value of the length record component
    • node

      public @Nullable Node node()
      Returns the value of the node record component.
      Returns:
      the value of the node record component
    • defaultLevel

      public CheckLevel defaultLevel()
      Returns the value of the defaultLevel record component.
      Returns:
      the value of the defaultLevel record component
    • requirement

      public @Nullable com.google.javascript.jscomp.Requirement requirement()
      Returns the value of the requirement record component.
      Returns:
      the value of the requirement record component