Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.control
Class ErrorCollector

    java.lang.Object
      org.codehaus.groovy.control.ErrorCollector

    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.

Version:
  $Id: ErrorCollector.java 21284 2010-12-10 20:19:09Z hamletdrc $
Author:
  Chris Poirier, Jochen Theodorou

Field Summary
Modifier and Type | Field and 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 Summary
Constructor and Description
`ErrorCollector(CompilerConfiguration configuration)` Initialize the ErrorReporter.

Method Summary
Modifier and Type | Method 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(String text, CSTNode context, SourceUnit source)` Convenience wrapper for addError().
`void` | `addError(SyntaxException error, SourceUnit source)` Convenience wrapper for addError().
`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(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.
`void` | `addWarning(WarningMessage message)` Adds a WarningMessage to the message set.
`protected void` | `failIfErrors()` Causes the current phase to fail by throwing a CompilationFailedException.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### warnings

    protected LinkedList warnings

  WarningMessages collected during processing

### errors

    protected LinkedList errors

  ErrorMessages collected during processing

### configuration

    protected CompilerConfiguration configuration

  Configuration and other settings that control processing

Constructor Detail

### ErrorCollector

    public ErrorCollector(CompilerConfiguration configuration)

  Initialize the ErrorReporter.

Method Detail

### addCollectorContents

    public void addCollectorContents(ErrorCollector er)

### addErrorAndContinue

    public 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.

### addError

    public 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`

### addError

    public 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`

### addError

    public void addError(SyntaxException error,
                         SourceUnit source)
                  throws CompilationFailedException

  Convenience wrapper for addError().

  Throws:
    `CompilationFailedException`

### addError

    public void addError(String text,
                         CSTNode context,
                         SourceUnit source)
                  throws CompilationFailedException

  Convenience wrapper for addError().

  Throws:
    `CompilationFailedException`

### addFatalError

    public void addFatalError(Message message)
                       throws CompilationFailedException

  Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.

  Throws:
    `CompilationFailedException`

### addException

    public void addException(Exception cause,
                             SourceUnit source)
                      throws CompilationFailedException

  Throws:
    `CompilationFailedException`

### hasErrors

    public boolean hasErrors()

  Returns true if there are any errors pending.

### hasWarnings

    public boolean hasWarnings()

  Returns true if there are any warnings pending.

### getWarnings

    public List getWarnings()

  Returns the list of warnings, or null if there are none.

### getErrors

    public List getErrors()

  Returns the list of errors, or null if there are none.

### getWarningCount

    public int getWarningCount()

  Returns the number of warnings.

### getErrorCount

    public int getErrorCount()

  Returns the number of errors.

### getWarning

    public WarningMessage getWarning(int index)

  Returns the specified warning message, or null.

### getError

    public Message getError(int index)

  Returns the specified error message, or null.

### getLastError

    public Message getLastError()

  Returns the last error reported

### getSyntaxError

    public SyntaxException getSyntaxError(int index)

  Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.

### getException

    public Exception getException(int index)

  Convenience routine to return the specified error's underlying Exception, or null if it isn't one.

### addWarning

    public void addWarning(WarningMessage message)

  Adds a WarningMessage to the message set.

### addWarning

    public void addWarning(int importance,
                           String text,
                           CSTNode context,
                           SourceUnit source)

  Convenience wrapper for addWarning() that won't create an object unless it is relevant.

### addWarning

    public 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.

### failIfErrors

    protected void failIfErrors()
                         throws CompilationFailedException

  Causes the current phase to fail by throwing a CompilationFailedException.

  Throws:
    `CompilationFailedException`

### write

    public void write(PrintWriter writer,
                      Janitor janitor)

  Writes error messages to the specified PrintWriter.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2003-2010 The Codehaus. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD