Package com.google.javascript.jscomp
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 sourcelineno- 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 theWarningsGuards 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 Summary
ConstructorsConstructorDescriptionJSError(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 aJSErrorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcharno()Returns the value of thecharnorecord component.Returns the value of thedefaultLevelrecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final @Nullable Stringformat(CheckLevel level, MessageFormatter formatter) Format a message at the given level.intintintfinal intAlias forgetLineno().@Nullable NodegetNode()final int@Nullable com.google.javascript.jscomp.Requirement@Nullable StringgetType()final inthashCode()Returns a hash code value for this object.intlength()Returns the value of thelengthrecord component.intlineno()Returns the value of thelinenorecord component.static JSErrormake(DiagnosticType type, String... arguments) Creates a JSError with no source informationstatic JSErrormake(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments) Creates a JSError from a requirement, file and Node position.static JSErrormake(Node n, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSErrormake(Node start, Node end, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSErrormake(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments) Creates a JSError at a given source location@Nullable Nodenode()Returns the value of thenoderecord component.@Nullable com.google.javascript.jscomp.RequirementReturns the value of therequirementrecord component.@Nullable StringReturns the value of thesourceNamerecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
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 aJSErrorrecord class.- Parameters:
type- the value for thetyperecord componentdescription- the value for thedescriptionrecord componentsourceName- the value for thesourceNamerecord componentlineno- the value for thelinenorecord componentcharno- the value for thecharnorecord componentlength- the value for thelengthrecord componentnode- the value for thenoderecord componentdefaultLevel- the value for thedefaultLevelrecord componentrequirement- the value for therequirementrecord component
-
-
Method Details
-
getType
-
getDescription
-
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
-
getDefaultLevel
-
getRequirement
@InlineMe(replacement="this.requirement()") public @Nullable com.google.javascript.jscomp.Requirement getRequirement() -
make
Creates a JSError with no source information- Parameters:
type- The DiagnosticTypearguments- 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 namelineno- Line number with source file, or -1 if unknowncharno- Column number within line, or -1 for whole line.type- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
make
Creates a JSError from a file and Node position.- Parameters:
n- Determines the line and char position and source file nametype- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
make
Creates a JSError from a file and Node position.- Parameters:
start- Determines the line and char position and source file nameend- Determines the length of the error regiontype- The DiagnosticTypearguments- 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 failsn- Determines the line and char position and source file nametype- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
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. -
format
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 forgetLineno(). -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
sourceName
Returns the value of thesourceNamerecord component.- Returns:
- the value of the
sourceNamerecord component
-
lineno
public int lineno()Returns the value of thelinenorecord component.- Returns:
- the value of the
linenorecord component
-
charno
public int charno()Returns the value of thecharnorecord component.- Returns:
- the value of the
charnorecord component
-
length
public int length()Returns the value of thelengthrecord component.- Returns:
- the value of the
lengthrecord component
-
node
Returns the value of thenoderecord component.- Returns:
- the value of the
noderecord component
-
defaultLevel
Returns the value of thedefaultLevelrecord component.- Returns:
- the value of the
defaultLevelrecord component
-
requirement
public @Nullable com.google.javascript.jscomp.Requirement requirement()Returns the value of therequirementrecord component.- Returns:
- the value of the
requirementrecord component
-