Package com.github.javaparser
Class JavaToken
java.lang.Object
com.github.javaparser.JavaToken
A token from a parsed source file.
(Awkwardly named "Java"Token since JavaCC already generates an internal class Token.)
It is a node in a double linked list called token list.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()voidLinks the tokens around the current token together, making the current token disappear from the list.booleanintgetKind()getRange()getText()inthashCode()booleanhasRange()voidInserts newToken into the token list just before this token.voidinsertAfter(JavaToken newToken)Inserts newToken into the token list just after this token.booleaninvalid()Used by the parser while constructing nodes.voidreplaceToken(JavaToken newToken)Replaces the current token with newToken.voidvoidtoString()booleanvalid()Used by the parser while constructing nodes.
-
Field Details
-
INVALID
-
-
Constructor Details
-
JavaToken
-
JavaToken
public JavaToken(int kind)Create a token of a certain kind. -
JavaToken
-
-
Method Details
-
getRange
-
hasRange
public boolean hasRange() -
getKind
public int getKind() -
getText
-
getNextToken
-
getPreviousToken
-
setRange
-
setText
-
asString
-
toTokenRange
- Returns:
- the token range that goes from the beginning to the end of the token list this token is a part of.
-
toString
-
valid
public boolean valid()Used by the parser while constructing nodes. No tokens should be invalid when the parser is done. -
invalid
public boolean invalid()Used by the parser while constructing nodes. No tokens should be invalid when the parser is done. -
getCategory
-
insert
Inserts newToken into the token list just before this token. -
insertAfter
Inserts newToken into the token list just after this token. -
deleteToken
public void deleteToken()Links the tokens around the current token together, making the current token disappear from the list. -
replaceToken
Replaces the current token with newToken. -
findLastToken
- Returns:
- the last token in the token list.
-
findFirstToken
- Returns:
- the first token in the token list.
-
hashCode
public int hashCode() -
equals
-