Package org.codehaus.groovy.control
Class ErrorCollector
- java.lang.Object
- 
- org.codehaus.groovy.control.ErrorCollector
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 public class ErrorCollector extends java.lang.Object implements java.io.SerializableA 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:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected CompilerConfigurationconfigurationConfiguration and other settings that control processingprotected java.util.LinkedListerrorsErrorMessages collected during processingprotected java.util.LinkedListwarningsWarningMessages collected during processing
 - 
Constructor SummaryConstructors Constructor Description ErrorCollector(CompilerConfiguration configuration)Initialize the ErrorReporter.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCollectorContents(ErrorCollector er)voidaddError(java.lang.String text, CSTNode context, SourceUnit source)Convenience wrapper for addError().voidaddError(Message message)Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded.voidaddError(Message message, boolean fatal)Adds an optionally-fatal error to the message set.voidaddError(SyntaxException error, SourceUnit source)Convenience wrapper for addError().voidaddErrorAndContinue(Message message)Adds an error to the message set, but does not cause a failure.voidaddErrorAndContinue(SyntaxException error, SourceUnit source)voidaddException(java.lang.Exception cause, SourceUnit source)voidaddFatalError(Message message)Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.voidaddWarning(int importance, java.lang.String text, java.lang.Object data, CSTNode context, SourceUnit source)Convenience wrapper for addWarning() that won't create an object unless it is relevant.voidaddWarning(int importance, java.lang.String text, CSTNode context, SourceUnit source)Convenience wrapper for addWarning() that won't create an object unless it is relevant.voidaddWarning(WarningMessage message)Adds a WarningMessage to the message set.protected voidfailIfErrors()Causes the current phase to fail by throwing a CompilationFailedException.CompilerConfigurationgetConfiguration()MessagegetError(int index)Returns the specified error message, or null.intgetErrorCount()Returns the number of errors.java.util.ListgetErrors()Returns the list of errors, or null if there are none.java.lang.ExceptiongetException(int index)Convenience routine to return the specified error's underlying Exception, or null if it isn't one.MessagegetLastError()Returns the last error reportedSyntaxExceptiongetSyntaxError(int index)Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.WarningMessagegetWarning(int index)Returns the specified warning message, or null.intgetWarningCount()Returns the number of warnings.java.util.ListgetWarnings()Returns the list of warnings, or null if there are none.booleanhasErrors()Returns true if there are any errors pending.booleanhasWarnings()Returns true if there are any warnings pending.voidwrite(java.io.PrintWriter writer, Janitor janitor)Writes error messages to the specified PrintWriter.
 
- 
- 
- 
Field Detail- 
warningsprotected java.util.LinkedList warnings WarningMessages collected during processing
 - 
errorsprotected java.util.LinkedList errors ErrorMessages collected during processing
 - 
configurationprotected CompilerConfiguration configuration Configuration and other settings that control processing
 
- 
 - 
Constructor Detail- 
ErrorCollectorpublic ErrorCollector(CompilerConfiguration configuration) Initialize the ErrorReporter.
 
- 
 - 
Method Detail- 
addCollectorContentspublic void addCollectorContents(ErrorCollector er) 
 - 
addErrorAndContinuepublic void addErrorAndContinue(SyntaxException error, SourceUnit source) throws CompilationFailedException - Throws:
- CompilationFailedException
 
 - 
addErrorAndContinuepublic void addErrorAndContinue(Message message) 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.
 - 
addErrorpublic void addError(Message message) throws CompilationFailedException 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.- Throws:
- CompilationFailedException
 
 - 
addErrorpublic void addError(Message message, boolean fatal) throws CompilationFailedException 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.- Parameters:
- fatal- if true then then processing will stop
- Throws:
- CompilationFailedException
 
 - 
addErrorpublic void addError(SyntaxException error, SourceUnit source) throws CompilationFailedException Convenience wrapper for addError().- Throws:
- CompilationFailedException
 
 - 
addErrorpublic void addError(java.lang.String text, CSTNode context, SourceUnit source) throws CompilationFailedExceptionConvenience wrapper for addError().- Throws:
- CompilationFailedException
 
 - 
addFatalErrorpublic void addFatalError(Message message) throws CompilationFailedException Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.- Throws:
- CompilationFailedException
 
 - 
addExceptionpublic void addException(java.lang.Exception cause, SourceUnit source) throws CompilationFailedException- Throws:
- CompilationFailedException
 
 - 
hasErrorspublic boolean hasErrors() Returns true if there are any errors pending.
 - 
getConfigurationpublic CompilerConfiguration getConfiguration() - Returns:
- the compiler configuration used to create this error collector
 
 - 
hasWarningspublic boolean hasWarnings() Returns true if there are any warnings pending.
 - 
getWarningspublic java.util.List getWarnings() Returns the list of warnings, or null if there are none.
 - 
getErrorspublic java.util.List getErrors() Returns the list of errors, or null if there are none.
 - 
getWarningCountpublic int getWarningCount() Returns the number of warnings.
 - 
getErrorCountpublic int getErrorCount() Returns the number of errors.
 - 
getWarningpublic WarningMessage getWarning(int index) Returns the specified warning message, or null.
 - 
getErrorpublic Message getError(int index) Returns the specified error message, or null.
 - 
getLastErrorpublic Message getLastError() Returns the last error reported
 - 
getSyntaxErrorpublic SyntaxException getSyntaxError(int index) Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.
 - 
getExceptionpublic java.lang.Exception getException(int index) Convenience routine to return the specified error's underlying Exception, or null if it isn't one.
 - 
addWarningpublic void addWarning(WarningMessage message) Adds a WarningMessage to the message set.
 - 
addWarningpublic void addWarning(int importance, java.lang.String text, CSTNode context, SourceUnit source)Convenience wrapper for addWarning() that won't create an object unless it is relevant.
 - 
addWarningpublic void addWarning(int importance, java.lang.String text, java.lang.Object data, CSTNode context, SourceUnit source)Convenience wrapper for addWarning() that won't create an object unless it is relevant.
 - 
failIfErrorsprotected void failIfErrors() throws CompilationFailedExceptionCauses the current phase to fail by throwing a CompilationFailedException.- Throws:
- CompilationFailedException
 
 - 
writepublic void write(java.io.PrintWriter writer, Janitor janitor)Writes error messages to the specified PrintWriter.
 
- 
 
-