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 Summary
Constructors Constructor Description AntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment, TextDocument textDoc)Deprecated.Don't create antlr tokens directly, use anAntlrTokenManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(AntlrToken o)This must return true if this token comes before the other token.CharSequencegetImageCs()Returns the text of the token as a char sequence.intgetKind()Gets a unique integer representing the kind of token this is.AntlrTokengetNext()Obtain the next generic token according to the input stream which generated the instance of this token.AntlrTokengetPreviousComment()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).TextRegiongetRegion()Returns a text region with the coordinates of this token.FileLocationgetReportLocation()Returns the location at which this element should be reported.booleanisDefault()booleanisEof()Returns true if this token is an end-of-file token.booleanisHidden()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.GenericToken
getImage, imageEquals, isImplicit
-
-
-
-
Constructor Detail
-
AntlrToken
@Deprecated public AntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment, TextDocument textDoc)
Deprecated.Don't create antlr tokens directly, use anAntlrTokenManagerConstructor- Parameters:
token- The antlr token implementationpreviousComment- The previous commenttextDoc- The text document
-
-
Method Detail
-
getNext
public AntlrToken getNext()
Description copied from interface:GenericTokenObtain the next generic token according to the input stream which generated the instance of this token.- Specified by:
getNextin interfaceGenericToken<AntlrToken>- Returns:
- the next generic token if it exists; null if it does not exist
-
getPreviousComment
public AntlrToken getPreviousComment()
Description copied from interface:GenericTokenObtain 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:
getPreviousCommentin interfaceGenericToken<AntlrToken>- Returns:
- the comment-type token if it exists; null if it does not exist
-
getImageCs
public CharSequence getImageCs()
Description copied from interface:GenericTokenReturns the text of the token as a char sequence. This should be preferred when you can use egStringUtilsto do some processing, without having to create a string.- Specified by:
getImageCsin interfaceGenericToken<AntlrToken>
-
getRegion
public TextRegion getRegion()
Returns a text region with the coordinates of this token.- Specified by:
getRegionin interfaceGenericToken<AntlrToken>
-
getReportLocation
public FileLocation getReportLocation()
Description copied from interface:ReportableReturns the location at which this element should be reported.Use this instead of
Node.getBeginColumn()/Node.getBeginLine(), etc.- Specified by:
getReportLocationin interfaceReportable
-
isEof
public boolean isEof()
Description copied from interface:GenericTokenReturns 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:
isEofin interfaceGenericToken<AntlrToken>
-
compareTo
public int compareTo(AntlrToken o)
Description copied from interface:GenericTokenThis 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:
compareToin interfaceComparable<AntlrToken>- Specified by:
compareToin interfaceGenericToken<AntlrToken>
-
getKind
public int getKind()
Description copied from interface:GenericTokenGets 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:
getKindin interfaceGenericToken<AntlrToken>
-
isHidden
public boolean isHidden()
-
isDefault
public boolean isDefault()
-
-