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 theWarningsGuard
s 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 aJSError
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
charno()
Returns the value of thecharno
record component.Returns the value of thedefaultLevel
record component.Returns the value of thedescription
record component.final boolean
Indicates whether some other object is "equal to" this one.final @Nullable String
format
(CheckLevel level, MessageFormatter formatter) Format a message at the given level.int
int
int
final int
Alias forgetLineno()
.@Nullable Node
getNode()
final int
@Nullable com.google.javascript.jscomp.Requirement
@Nullable String
getType()
final int
hashCode()
Returns a hash code value for this object.int
length()
Returns the value of thelength
record component.int
lineno()
Returns the value of thelineno
record component.static JSError
make
(DiagnosticType type, String... arguments) Creates a JSError with no source informationstatic JSError
make
(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments) Creates a JSError from a requirement, file and Node position.static JSError
make
(Node n, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSError
make
(Node start, Node end, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSError
make
(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments) Creates a JSError at a given source location@Nullable Node
node()
Returns the value of thenode
record component.@Nullable com.google.javascript.jscomp.Requirement
Returns the value of therequirement
record component.@Nullable String
Returns the value of thesourceName
record component.final String
toString()
Returns a string representation of this record class.type()
Returns the value of thetype
record 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 aJSError
record class.- Parameters:
type
- the value for thetype
record componentdescription
- the value for thedescription
record componentsourceName
- the value for thesourceName
record componentlineno
- the value for thelineno
record componentcharno
- the value for thecharno
record componentlength
- the value for thelength
record componentnode
- the value for thenode
record componentdefaultLevel
- the value for thedefaultLevel
record componentrequirement
- the value for therequirement
record 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 thetype
record component.- Returns:
- the value of the
type
record component
-
description
Returns the value of thedescription
record component.- Returns:
- the value of the
description
record component
-
sourceName
Returns the value of thesourceName
record component.- Returns:
- the value of the
sourceName
record component
-
lineno
public int lineno()Returns the value of thelineno
record component.- Returns:
- the value of the
lineno
record component
-
charno
public int charno()Returns the value of thecharno
record component.- Returns:
- the value of the
charno
record component
-
length
public int length()Returns the value of thelength
record component.- Returns:
- the value of the
length
record component
-
node
Returns the value of thenode
record component.- Returns:
- the value of the
node
record component
-
defaultLevel
Returns the value of thedefaultLevel
record component.- Returns:
- the value of the
defaultLevel
record component
-
requirement
public @Nullable com.google.javascript.jscomp.Requirement requirement()Returns the value of therequirement
record component.- Returns:
- the value of the
requirement
record component
-