public interface Diagnostic
Interface for diagnostics from tools. A diagnostic usually reports
a problem at a specific position in a source file. However, not
all diagnostics are associated with a position or a file.
A position is a zero-based character offset from the beginning of
a file. Negative values (except NOPOS
) are not valid
positions.
Line and column numbers begin at 1. Negative values (except
NOPOS
) and 0 are not valid line or column numbers.
Line terminator is as defined in ECMAScript specification which is one of { \u000A, \u000B, \u2028, \u2029 }.
- Since:
- 9
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Kinds of diagnostics, for example, error or warning. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Used to signal that no position is available. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()
Gets a diagnostic code indicating the type of diagnostic.long
Gets the column number of the character offset returned by getPosition().Gets the source file name.getKind()
Gets the kind of this diagnostic, for example, error or warning.long
Gets the line number of the character offset returned by getPosition().Gets a message for this diagnostic.long
Gets a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem.
-
Field Details
-
NOPOS
static final long NOPOSUsed to signal that no position is available.- See Also:
-
-
Method Details
-
getKind
Diagnostic.Kind getKind()Gets the kind of this diagnostic, for example, error or warning.- Returns:
- the kind of this diagnostic
-
getPosition
long getPosition()Gets a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem. In addition, the following must be true:getStartPostion() <= getPosition()
getPosition() <= getEndPosition()
- Returns:
- character offset from beginning of source;
NOPOS
if no location is suitable
-
getFileName
String getFileName()Gets the source file name.- Returns:
- the file name or null if not available
-
getLineNumber
long getLineNumber()Gets the line number of the character offset returned by getPosition().- Returns:
- a line number or
NOPOS
if and only ifgetPosition()
returnsNOPOS
-
getColumnNumber
long getColumnNumber()Gets the column number of the character offset returned by getPosition().- Returns:
- a column number or
NOPOS
if and only ifgetPosition()
returnsNOPOS
-
getCode
String getCode()Gets a diagnostic code indicating the type of diagnostic. The code is implementation-dependent and might benull
.- Returns:
- a diagnostic code
-
getMessage
String getMessage()Gets a message for this diagnostic.- Returns:
- a message
-