public class ErrorCollector extends Object
A base class for collecting messages and errors during processing. Each CompilationUnit should have an ErrorCollector, and the SourceUnits should share their ErrorCollector with the CompilationUnit.
Modifiers | Name | Description |
---|---|---|
protected CompilerConfiguration |
configuration |
Configuration and other settings that control processing |
protected LinkedList |
errors |
ErrorMessages collected during processing |
protected LinkedList |
warnings |
WarningMessages collected during processing |
Constructor and description |
---|
ErrorCollector
(CompilerConfiguration configuration) Initialize the ErrorReporter. |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
addCollectorContents(ErrorCollector er) |
|
void |
addError(Message message) Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded. |
|
void |
addError(Message message, boolean fatal) Adds an optionally-fatal error to the message set. |
|
void |
addError(SyntaxException error, SourceUnit source) Convenience wrapper for addError(). |
|
void |
addError(String text, CSTNode context, SourceUnit source) Convenience wrapper for addError(). |
|
void |
addErrorAndContinue(SyntaxException error, SourceUnit source) |
|
void |
addErrorAndContinue(Message message) Adds an error to the message set, but does not cause a failure. |
|
void |
addException(Exception cause, SourceUnit source) |
|
void |
addFatalError(Message message) Adds a fatal exception to the message set and throws the unit as a PhaseFailedException. |
|
void |
addWarning(WarningMessage message) Adds a WarningMessage to the message set. |
|
void |
addWarning(int importance, String text, CSTNode context, SourceUnit source) Convenience wrapper for addWarning() that won't create an object unless it is relevant. |
|
void |
addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source) Convenience wrapper for addWarning() that won't create an object unless it is relevant. |
|
protected void |
failIfErrors() Causes the current phase to fail by throwing a CompilationFailedException. |
|
CompilerConfiguration |
getConfiguration() @return the compiler configuration used to create this error collector |
|
Message |
getError(int index) Returns the specified error message, or null. |
|
int |
getErrorCount() Returns the number of errors. |
|
List |
getErrors() Returns the list of errors, or null if there are none. |
|
Exception |
getException(int index) Convenience routine to return the specified error's underlying Exception, or null if it isn't one. |
|
Message |
getLastError() Returns the last error reported |
|
SyntaxException |
getSyntaxError(int index) Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one. |
|
WarningMessage |
getWarning(int index) Returns the specified warning message, or null. |
|
int |
getWarningCount() Returns the number of warnings. |
|
List |
getWarnings() Returns the list of warnings, or null if there are none. |
|
boolean |
hasErrors() Returns true if there are any errors pending. |
|
boolean |
hasWarnings() Returns true if there are any warnings pending. |
|
void |
write(PrintWriter writer, Janitor janitor) Writes error messages to the specified PrintWriter. |
Configuration and other settings that control processing
ErrorMessages collected during processing
WarningMessages collected during processing
Initialize the ErrorReporter.
Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded. The message is not required to have a source line and column specified, but it is best practice to try and include that information.
Adds an optionally-fatal error to the message set. The message is not required to have a source line and column specified, but it is best practice to try and include that information.
fatal
- if true then then processing will stopConvenience wrapper for addError().
Convenience wrapper for addError().
Adds an error to the message set, but does not cause a failure. The message is not required to have a source line and column specified, but it is best practice to try and include that information.
Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.
Adds a WarningMessage to the message set.
Convenience wrapper for addWarning() that won't create an object unless it is relevant.
Convenience wrapper for addWarning() that won't create an object unless it is relevant.
Causes the current phase to fail by throwing a CompilationFailedException.
Returns the specified error message, or null.
Returns the number of errors.
Returns the list of errors, or null if there are none.
Convenience routine to return the specified error's underlying Exception, or null if it isn't one.
Returns the last error reported
Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.
Returns the specified warning message, or null.
Returns the number of warnings.
Returns the list of warnings, or null if there are none.
Returns true if there are any errors pending.
Returns true if there are any warnings pending.
Writes error messages to the specified PrintWriter.
Copyright © 2003-2021 The Apache Software Foundation. All rights reserved.