Enum Class ErrorFormat

java.lang.Object
java.lang.Enum<ErrorFormat>
org.codehaus.groovy.control.ErrorFormat
All Implemented Interfaces:
Serializable, Comparable<ErrorFormat>, Constable

public enum ErrorFormat extends Enum<ErrorFormat>
How compilation errors and warnings are rendered (GROOVY-12312).

Each constant is a renderer which owns the layout of a whole report; the Message classes only say what went wrong and where, via Message.toDiagnostic(). A format is selected with CompilerConfiguration.setErrorFormat(ErrorFormat) and applied by ErrorCollector.write(PrintWriter, Janitor). Adding a layout means adding a constant here, not touching the messages.

Since:
6.0.0
  • Enum Constant Details

    • FULL

      public static final ErrorFormat FULL
      The default, human-oriented rendering: each message as Message.write(PrintWriter, Janitor) lays it out, typically with the offending source line and a caret marking the column, followed by a blank line; then a count per severity.
    • SHORT

      public static final ErrorFormat SHORT
      One line per diagnostic, in the file:line:column: severity: message form understood by most editors and CI log parsers; then a count per severity. The source line and caret are omitted, and a message spanning several lines is joined into one. Parts a message does not have are dropped rather than guessed: no file when there is no source unit, no line and column when there is no position.
  • Method Details

    • values

      public static ErrorFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ErrorFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • write

      public abstract void write(PrintWriter writer, Janitor janitor, List<? extends Message> warnings, List<? extends Message> errors, boolean debug)
      Renders a complete report: the warnings, then the errors.
      Parameters:
      writer - the destination
      janitor - the cleanup helper for temporary source access, may be null
      warnings - the warnings, may be null or empty
      errors - the errors, may be null or empty
      debug - whether to follow each syntax error with its stack trace
    • toString

      public String toString()
      The lower-case form used on the command line and in help text, e.g. short. picocli matches an option value against this as well as Enum.name(), so --error-format=short and --error-format=SHORT both parse.
      Overrides:
      toString in class Enum<ErrorFormat>