Package com.github.javaparser
Class JavaToken
- java.lang.Object
-
- com.github.javaparser.JavaToken
-
public class JavaToken extends Object
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 Modifier and Type Class Description static classJavaToken.Categorystatic classJavaToken.Kind
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringasString()voiddeleteToken()Links the tokens around the current token together, making the current token disappear from the list.booleanequals(Object o)JavaTokenfindFirstToken()JavaTokenfindLastToken()JavaToken.CategorygetCategory()intgetKind()Optional<JavaToken>getNextToken()Optional<JavaToken>getPreviousToken()Optional<Range>getRange()StringgetText()inthashCode()voidinsert(JavaToken newToken)Inserts 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.voidsetRange(Range range)voidsetText(String text)StringtoString()TokenRangetoTokenRange()booleanvalid()Used by the parser while constructing nodes.
-
-
-
Field Detail
-
INVALID
public static final JavaToken INVALID
-
-
Method Detail
-
getKind
public int getKind()
-
getText
public String getText()
-
setRange
public void setRange(Range range)
-
setText
public void setText(String text)
-
asString
public String asString()
-
toTokenRange
public TokenRange toTokenRange()
- Returns:
- the token range that goes from the beginning to the end of the token list this token is a part of.
-
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
public JavaToken.Category getCategory()
-
insert
public void insert(JavaToken newToken)
Inserts newToken into the token list just before this token.
-
insertAfter
public void insertAfter(JavaToken newToken)
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
public void replaceToken(JavaToken newToken)
Replaces the current token with newToken.
-
findLastToken
public JavaToken findLastToken()
- Returns:
- the last token in the token list.
-
findFirstToken
public JavaToken findFirstToken()
- Returns:
- the first token in the token list.
-
-