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 class
JavaToken.Category
static class
JavaToken.Kind
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
asString()
void
deleteToken()
Links the tokens around the current token together, making the current token disappear from the list.boolean
equals(Object o)
JavaToken
findFirstToken()
JavaToken
findLastToken()
JavaToken.Category
getCategory()
int
getKind()
Optional<JavaToken>
getNextToken()
Optional<JavaToken>
getPreviousToken()
Optional<Range>
getRange()
String
getText()
int
hashCode()
void
insert(JavaToken newToken)
Inserts newToken into the token list just before this token.void
insertAfter(JavaToken newToken)
Inserts newToken into the token list just after this token.boolean
invalid()
Used by the parser while constructing nodes.void
replaceToken(JavaToken newToken)
Replaces the current token with newToken.void
setRange(Range range)
void
setText(String text)
String
toString()
TokenRange
toTokenRange()
boolean
valid()
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.
-
-