Package org.codehaus.groovy.control
Class ErrorCollector
java.lang.Object
org.codehaus.groovy.control.ErrorCollector
- All Implemented Interfaces:
- Serializable
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.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final CompilerConfigurationConfiguration and other settings that control processingprotected LinkedList<Message>ErrorMessages collected during processingprotected LinkedList<WarningMessage>WarningMessages collected during processing
- 
Constructor SummaryConstructorsConstructorDescriptionErrorCollector(CompilerConfiguration configuration) Initialize the ErrorReporter.
- 
Method SummaryModifier and TypeMethodDescriptionvoidvoidaddError(String error, CSTNode context, SourceUnit source) voidAdds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded.voidAdds an optionally-fatal error to the message set.voidaddError(SyntaxException error, SourceUnit source) voidaddErrorAndContinue(String error, ASTNode node, SourceUnit source) voidaddErrorAndContinue(Message message) Adds an error to the message set, but does not cause a failure.voidaddErrorAndContinue(SyntaxException error, SourceUnit source) voidaddException(Exception exception, SourceUnit source) voidaddFatalError(Message message) Adds an error to the message set and throws CompilationFailedException.voidaddWarning(int importance, String text, Object data, CSTNode context, SourceUnit source) Adds a warning to the message set if it is relevant.voidaddWarning(int importance, String text, CSTNode context, SourceUnit source) Adds a warning to the message set if it is relevant.voidaddWarning(WarningMessage message) Adds a warning to the message set.protected voidCauses the current phase to fail by throwing a CompilationFailedException.getError(int index) Returns the specified error message, or null.intReturns the number of errors.Returns the list of errors, or null if there are none.getException(int index) Returns the specified error's underlying Exception, or null if it isn't one.Returns the last error reported.getSyntaxError(int index) Returns the specified error's underlying SyntaxException, or null if it isn't one.getWarning(int index) Returns the specified warning message, or null.intReturns the number of warnings.Returns the list of warnings, or null if there are none.booleanReturns true if there are any errors pending.booleanReturns true if there are any warnings pending.voidwrite(PrintWriter writer, Janitor janitor) Writes error messages to the specified PrintWriter.
- 
Field Details- 
errorsErrorMessages collected during processing
- 
warningsWarningMessages collected during processing
- 
configurationConfiguration and other settings that control processing
 
- 
- 
Constructor Details- 
ErrorCollectorInitialize the ErrorReporter.
 
- 
- 
Method Details- 
addCollectorContents
- 
addErrorAndContinue
- 
addErrorAndContinue
- 
addErrorAndContinueAdds 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.
- 
addErrorAdds 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.- Throws:
- CompilationFailedException
 
- 
addErrorAdds 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.- Parameters:
- fatal- if true then processing will stop
- Throws:
- CompilationFailedException
 
- 
addError- Throws:
- CompilationFailedException
 
- 
addErrorpublic void addError(String error, CSTNode context, SourceUnit source) throws CompilationFailedException - Throws:
- CompilationFailedException
 
- 
addException- Throws:
- CompilationFailedException
 
- 
addFatalErrorAdds an error to the message set and throws CompilationFailedException.- Throws:
- CompilationFailedException
 
- 
addWarningAdds a warning to the message set.
- 
addWarningAdds a warning to the message set if it is relevant.
- 
addWarningpublic void addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source) Adds a warning to the message set if it is relevant.
- 
getConfiguration- Returns:
- the compiler configuration used to create this error collector
 
- 
getErrorCountpublic int getErrorCount()Returns the number of errors.
- 
getErrorReturns the specified error message, or null.
- 
getErrorsReturns the list of errors, or null if there are none.
- 
hasErrorspublic boolean hasErrors()Returns true if there are any errors pending.
- 
getWarningCountpublic int getWarningCount()Returns the number of warnings.
- 
getWarningReturns the specified warning message, or null.
- 
getWarningsReturns the list of warnings, or null if there are none.
- 
hasWarningspublic boolean hasWarnings()Returns true if there are any warnings pending.
- 
getLastErrorReturns the last error reported.
- 
getExceptionReturns the specified error's underlying Exception, or null if it isn't one.
- 
getSyntaxErrorReturns the specified error's underlying SyntaxException, or null if it isn't one.
- 
failIfErrorsCauses the current phase to fail by throwing a CompilationFailedException.- Throws:
- CompilationFailedException
 
- 
writeWrites error messages to the specified PrintWriter.
 
-