Package com.google.javascript.jscomp
Class JSError
- java.lang.Object
-
- com.google.javascript.jscomp.JSError
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class JSError extends java.lang.Object implements java.io.Serializable
Compile error description.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @Nullable java.lang.String
format(CheckLevel level, MessageFormatter formatter)
Format a message at the given level.abstract int
getCharno()
Zero-indexed character number of the error location.abstract CheckLevel
getDefaultLevel()
The default level, before any of theWarningsGuard
s are applied.abstract java.lang.String
getDescription()
Description of the error.abstract int
getLineno()
One-indexed line number of the error location.int
getLineNumber()
Alias forgetLineno()
.abstract @Nullable Node
getNode()
Node where the warning occurred.int
getNodeLength()
int
getNodeSourceOffset()
abstract @Nullable java.lang.String
getSourceName()
Name of the sourceabstract DiagnosticType
getType()
A type of the error.static JSError
make(DiagnosticType type, java.lang.String... arguments)
Creates a JSError with no source informationstatic JSError
make(Node n, DiagnosticType type, java.lang.String... arguments)
Creates a JSError from a file and Node position.static JSError
make(java.lang.String sourceName, int lineno, int charno, DiagnosticType type, java.lang.String... arguments)
Creates a JSError at a given source locationjava.lang.String
toString()
-
-
-
Method Detail
-
getType
public abstract DiagnosticType getType()
A type of the error.
-
getDescription
public abstract java.lang.String getDescription()
Description of the error.
-
getSourceName
public abstract @Nullable java.lang.String getSourceName()
Name of the source
-
getLineno
public abstract int getLineno()
One-indexed line number of the error location.
-
getCharno
public abstract int getCharno()
Zero-indexed character number of the error location.
-
getNode
public abstract @Nullable Node getNode()
Node where the warning occurred.
-
getDefaultLevel
public abstract CheckLevel getDefaultLevel()
The default level, before any of theWarningsGuard
s are applied.
-
make
public static JSError make(DiagnosticType type, java.lang.String... arguments)
Creates a JSError with no source information- Parameters:
type
- The DiagnosticTypearguments
- Arguments to be incorporated into the message
-
make
public static JSError make(java.lang.String sourceName, int lineno, int charno, DiagnosticType type, java.lang.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
public static JSError make(Node n, DiagnosticType type, java.lang.String... arguments)
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
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the default rendering of an error as text.
-
format
public final @Nullable java.lang.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.
-
getNodeLength
public final int getNodeLength()
- Returns:
- the length of the region the Error applies to, or 0 if the length is unknown.
-
getLineNumber
public final int getLineNumber()
Alias forgetLineno()
.
-
-