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 int
compareTo(AntlrToken o)
This must return true if this token comes before the other token.CharSequence
getImageCs()
Returns the text of the token as a char sequence.int
getKind()
Gets a unique integer representing the kind of token this is.AntlrToken
getNext()
Obtain the next generic token according to the input stream which generated the instance of this token.AntlrToken
getPreviousComment()
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).TextRegion
getRegion()
Returns a text region with the coordinates of this token.FileLocation
getReportLocation()
Returns the location at which this element should be reported.boolean
isDefault()
boolean
isEof()
Returns true if this token is an end-of-file token.boolean
isHidden()
-
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 anAntlrTokenManager
Constructor- Parameters:
token
- The antlr token implementationpreviousComment
- The previous commenttextDoc
- The text document
-
-
Method Detail
-
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 interfaceGenericToken<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 interfaceGenericToken<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 egStringUtils
to do some processing, without having to create a string.- Specified by:
getImageCs
in interfaceGenericToken<AntlrToken>
-
getRegion
public TextRegion getRegion()
Returns a text region with the coordinates of this token.- Specified by:
getRegion
in interfaceGenericToken<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 interfaceReportable
-
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 interfaceGenericToken<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 interfaceComparable<AntlrToken>
- Specified by:
compareTo
in interfaceGenericToken<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 interfaceGenericToken<AntlrToken>
-
isHidden
public boolean isHidden()
-
isDefault
public boolean isDefault()
-
-