public class ErrorCollector extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected CompilerConfiguration |
configuration
Configuration and other settings that control processing
|
protected LinkedList<Message> |
errors
ErrorMessages collected during processing
|
protected LinkedList<WarningMessage> |
warnings
WarningMessages collected during processing
|
Constructor and Description |
---|
ErrorCollector(CompilerConfiguration configuration)
Initialize the ErrorReporter.
|
Modifier and Type | Method and Description |
---|---|
void |
addCollectorContents(ErrorCollector that) |
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(String error,
CSTNode context,
SourceUnit source) |
void |
addError(SyntaxException error,
SourceUnit source) |
void |
addErrorAndContinue(Message message)
Adds an error to the message set, but does not cause a failure.
|
void |
addErrorAndContinue(SyntaxException error,
SourceUnit source) |
void |
addException(Exception exception,
SourceUnit source) |
void |
addFatalError(Message message)
Adds an error to the message set and throws CompilationFailedException.
|
void |
addWarning(int importance,
String text,
CSTNode context,
SourceUnit source)
Adds a warning to the message set if it is relevant.
|
void |
addWarning(int importance,
String text,
Object data,
CSTNode context,
SourceUnit source)
Adds a warning to the message set if it is relevant.
|
void |
addWarning(WarningMessage message)
Adds a warning to the message set.
|
protected void |
failIfErrors()
Causes the current phase to fail by throwing a CompilationFailedException.
|
CompilerConfiguration |
getConfiguration() |
Message |
getError(int index)
Returns the specified error message, or null.
|
int |
getErrorCount()
Returns the number of errors.
|
List<? extends Message> |
getErrors()
Returns the list of errors, or null if there are none.
|
Exception |
getException(int index)
Returns the specified error's underlying Exception, or null if it isn't one.
|
Message |
getLastError()
Returns the last error reported.
|
SyntaxException |
getSyntaxError(int index)
Returns 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<WarningMessage> |
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.
|
protected LinkedList<Message> errors
protected LinkedList<WarningMessage> warnings
protected final CompilerConfiguration configuration
public ErrorCollector(CompilerConfiguration configuration)
public void addCollectorContents(ErrorCollector that)
public void addErrorAndContinue(SyntaxException error, SourceUnit source) throws CompilationFailedException
CompilationFailedException
public void addErrorAndContinue(Message message)
public void addError(Message message) throws CompilationFailedException
CompilationFailedException
public void addError(Message message, boolean fatal) throws CompilationFailedException
fatal
- if true then then processing will stopCompilationFailedException
public void addError(SyntaxException error, SourceUnit source) throws CompilationFailedException
CompilationFailedException
public void addError(String error, CSTNode context, SourceUnit source) throws CompilationFailedException
CompilationFailedException
public void addException(Exception exception, SourceUnit source) throws CompilationFailedException
CompilationFailedException
public void addFatalError(Message message) throws CompilationFailedException
CompilationFailedException
public void addWarning(WarningMessage message)
public void addWarning(int importance, String text, CSTNode context, SourceUnit source)
public void addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source)
public CompilerConfiguration getConfiguration()
public int getErrorCount()
public Message getError(int index)
public List<? extends Message> getErrors()
public boolean hasErrors()
public int getWarningCount()
public WarningMessage getWarning(int index)
public List<WarningMessage> getWarnings()
public boolean hasWarnings()
public Message getLastError()
public Exception getException(int index)
public SyntaxException getSyntaxError(int index)
protected void failIfErrors() throws CompilationFailedException
CompilationFailedException
public void write(PrintWriter writer, Janitor janitor)