Class GroovySyntaxError

java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.AssertionError
org.apache.groovy.parser.antlr4.GroovySyntaxError
All Implemented Interfaces:
Serializable

public class GroovySyntaxError extends AssertionError
Represents a syntax error of a Groovy program, raised by the lexer or parser.

The message is the diagnostic as produced by the recogniser (for example Unclosed string literal or Unexpected character: '\u200b'). Line and column are 1-based caret coordinates. On the compiler's normal lexer path (SyntaxErrorReportable.require(boolean, java.lang.String, int, boolean) with toAttachPositionInfo false), the location is not part of the message string — SyntaxException appends @ line N, column M when wrapping the error. The public SyntaxErrorReportable.throwSyntaxError(java.lang.String, int, boolean) path can still append PositionInfo when toAttachPositionInfo is true (IDE / highlighter callers).

See Also:
  • Field Details

    • LEXER

      public static final int LEXER
      source value for an error raised by the lexer.
      See Also:
    • PARSER

      public static final int PARSER
      source value for an error raised by the parser.
      See Also:
  • Constructor Details

    • GroovySyntaxError

      public GroovySyntaxError(String message, int source, int line, int column)
      Creates an error with no cause. source must be LEXER or PARSER. line and column are stored as given; callers supply 1-based caret coordinates.

      Any other source is rejected.

      Parameters:
      message - the diagnostic text
      source - LEXER or PARSER
      line - the line stored for this error
      column - the column stored for this error
  • Method Details

    • getSource

      public int getSource()
      Returns the recogniser that raised this error.
      Returns:
      LEXER or PARSER
    • getLine

      public int getLine()
      Returns the line passed to the constructor.
      Returns:
      the stored line
    • getColumn

      public int getColumn()
      Returns the column passed to the constructor.
      Returns:
      the stored column