Class AntlrToken
java.lang.Object
net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken
- All Implemented Interfaces:
Comparable<AntlrToken>,GenericToken<AntlrToken>,Reportable
Generic Antlr representation of a token.
-
Constructor Summary
ConstructorsConstructorDescriptionAntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment, TextDocument textDoc) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionintThis must return true if this token comes before the other token.Returns the text of the token as a char sequence.intgetKind()Gets a unique integer representing the kind of token this is.getNext()Obtain the next generic token according to the input stream which generated the instance of this token.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).Returns a text region with the coordinates of this token.Returns the location at which this element should be reported.booleanbooleanisEof()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, waitMethods inherited from interface net.sourceforge.pmd.lang.ast.GenericToken
getImage, imageEquals, isImplicit
-
Constructor Details
-
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 Details
-
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
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
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
Returns a text region with the coordinates of this token.- Specified by:
getRegionin interfaceGenericToken<AntlrToken>
-
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
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()
-
AntlrTokenManager