Class AntlrToken

java.lang.Object
net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken
All Implemented Interfaces:
Comparable<AntlrToken>, GenericToken<AntlrToken>, Reportable

public class AntlrToken extends Object implements GenericToken<AntlrToken>
Generic Antlr representation of a token.
  • Constructor Details

    • AntlrToken

      @Deprecated public AntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment, TextDocument textDoc)
      Deprecated.
      Don't create antlr tokens directly, use an AntlrTokenManager
      Constructor
      Parameters:
      token - The antlr token implementation
      previousComment - The previous comment
      textDoc - The text document
  • Method Details

    • getNext

      public AntlrToken getNext()
      Description copied from interface: GenericToken
      Obtain the next generic token according to the input stream which generated the instance of this token.
      Specified by:
      getNext in interface GenericToken<AntlrToken>
      Returns:
      the next generic token if it exists; null if it does not exist
    • getPreviousComment

      public AntlrToken getPreviousComment()
      Description copied from interface: GenericToken
      Obtain a comment-type token which, according to the input stream which generated the instance of this token, precedes this instance token and succeeds the previous generic token (if there is any).
      Specified by:
      getPreviousComment in interface GenericToken<AntlrToken>
      Returns:
      the comment-type token if it exists; null if it does not exist
    • getImageCs

      public CharSequence getImageCs()
      Description copied from interface: GenericToken
      Returns the text of the token as a char sequence. This should be preferred when you can use eg StringUtils to do some processing, without having to create a string.
      Specified by:
      getImageCs in interface GenericToken<AntlrToken>
    • getRegion

      public TextRegion getRegion()
      Returns a text region with the coordinates of this token.
      Specified by:
      getRegion in interface GenericToken<AntlrToken>
    • getReportLocation

      public FileLocation getReportLocation()
      Description copied from interface: Reportable
      Returns the location at which this element should be reported.

      Use this instead of Node.getBeginColumn()/Node.getBeginLine(), etc.

      Specified by:
      getReportLocation in interface Reportable
    • isEof

      public boolean isEof()
      Description copied from interface: GenericToken
      Returns true if this token is an end-of-file token. This is the last token of token sequences that have been fully lexed.
      Specified by:
      isEof in interface GenericToken<AntlrToken>
    • compareTo

      public int compareTo(AntlrToken o)
      Description copied from interface: GenericToken
      This must return true if this token comes before the other token. If they start at the same index, then the smaller token comes before the other.
      Specified by:
      compareTo in interface Comparable<AntlrToken>
      Specified by:
      compareTo in interface GenericToken<AntlrToken>
    • getKind

      public int getKind()
      Description copied from interface: GenericToken
      Gets a unique integer representing the kind of token this is. The semantics of this kind depend on the language.

      The returned constants can be looked up in the language's "*ParserConstants", e.g. CppParserConstants or JavaParserConstants. These constants are considered internal API and may change at any time when the language's grammar is changed.

      Specified by:
      getKind in interface GenericToken<AntlrToken>
    • isHidden

      public boolean isHidden()
    • isDefault

      public boolean isDefault()