Package net.sourceforge.pmd.cpd.token
Class AntlrToken
- java.lang.Object
-
- net.sourceforge.pmd.cpd.token.AntlrToken
-
- All Implemented Interfaces:
GenericToken
public class AntlrToken extends Object implements GenericToken
Generic Antlr representation of a token.
-
-
Constructor Summary
Constructors Constructor Description AntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intgetBeginColumn()Gets the column offset from the start of the begin line where the token's region beginsintgetBeginLine()Gets the line where the token's region beginsintgetEndColumn()Gets the column offset from the start of the end line where the token's region endsintgetEndLine()Gets the line where the token's region endsStringgetImage()Gets the token's text.intgetKind()Gets a unique integer representing the kind of token this is.GenericTokengetNext()Obtain the next generic token according to the input stream which generated the instance of this token.GenericTokengetPreviousComment()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).intgetType()Deprecated.usegetKind()instead.booleanisDefault()booleanisHidden()
-
-
-
Constructor Detail
-
AntlrToken
public AntlrToken(org.antlr.v4.runtime.Token token, AntlrToken previousComment)Constructor- Parameters:
token- The antlr token implementationpreviousComment- The previous comment
-
-
Method Detail
-
getNext
public GenericToken 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- Returns:
- the next generic token if it exists; null if it does not exist
-
getPreviousComment
public GenericToken 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- Returns:
- the comment-type token if it exists; null if it does not exist
-
getImage
public String getImage()
Description copied from interface:GenericTokenGets the token's text.- Specified by:
getImagein interfaceGenericToken- Returns:
- the token's text
-
getBeginLine
public int getBeginLine()
Description copied from interface:GenericTokenGets the line where the token's region begins- Specified by:
getBeginLinein interfaceGenericToken- Returns:
- a non-negative integer containing the begin line
-
getBeginColumn
public int getBeginColumn()
Description copied from interface:GenericTokenGets the column offset from the start of the begin line where the token's region begins- Specified by:
getBeginColumnin interfaceGenericToken- Returns:
- a non-negative integer containing the begin column
-
getEndLine
public int getEndLine()
Description copied from interface:GenericTokenGets the line where the token's region ends- Specified by:
getEndLinein interfaceGenericToken- Returns:
- a non-negative integer containing the end line
-
getEndColumn
public int getEndColumn()
Description copied from interface:GenericTokenGets the column offset from the start of the end line where the token's region ends- Specified by:
getEndColumnin interfaceGenericToken- Returns:
- a non-negative integer containing the begin column
-
getKind
@Experimental 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.Note: This is an experimental API.
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
-
getType
@Deprecated public int getType()
Deprecated.usegetKind()instead.
-
isHidden
public boolean isHidden()
-
isDefault
public boolean isDefault()
-
-