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 int
getBeginColumn()
Gets the column offset from the start of the begin line where the token's region beginsint
getBeginLine()
Gets the line where the token's region beginsint
getEndColumn()
Gets the column offset from the start of the end line where the token's region endsint
getEndLine()
Gets the line where the token's region endsString
getImage()
Gets the token's text.int
getKind()
Gets a unique integer representing the kind of token this is.GenericToken
getNext()
Obtain the next generic token according to the input stream which generated the instance of this token.GenericToken
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).int
getType()
Deprecated.usegetKind()
instead.boolean
isDefault()
boolean
isHidden()
-
-
-
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:GenericToken
Obtain the next generic token according to the input stream which generated the instance of this token.- Specified by:
getNext
in interfaceGenericToken
- Returns:
- the next generic token if it exists; null if it does not exist
-
getPreviousComment
public GenericToken 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
- Returns:
- the comment-type token if it exists; null if it does not exist
-
getImage
public String getImage()
Description copied from interface:GenericToken
Gets the token's text.- Specified by:
getImage
in interfaceGenericToken
- Returns:
- the token's text
-
getBeginLine
public int getBeginLine()
Description copied from interface:GenericToken
Gets the line where the token's region begins- Specified by:
getBeginLine
in interfaceGenericToken
- Returns:
- a non-negative integer containing the begin line
-
getBeginColumn
public int getBeginColumn()
Description copied from interface:GenericToken
Gets the column offset from the start of the begin line where the token's region begins- Specified by:
getBeginColumn
in interfaceGenericToken
- Returns:
- a non-negative integer containing the begin column
-
getEndLine
public int getEndLine()
Description copied from interface:GenericToken
Gets the line where the token's region ends- Specified by:
getEndLine
in interfaceGenericToken
- Returns:
- a non-negative integer containing the end line
-
getEndColumn
public int getEndColumn()
Description copied from interface:GenericToken
Gets the column offset from the start of the end line where the token's region ends- Specified by:
getEndColumn
in interfaceGenericToken
- Returns:
- a non-negative integer containing the begin column
-
getKind
@Experimental 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.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:
getKind
in interfaceGenericToken
-
getType
@Deprecated public int getType()
Deprecated.usegetKind()
instead.
-
isHidden
public boolean isHidden()
-
isDefault
public boolean isDefault()
-
-