Package com.google.googlejavaformat.java
Class JavaInput.Tok
java.lang.Object
com.google.googlejavaformat.java.JavaInput.Tok
- All Implemented Interfaces:
Input.Tok
- Enclosing class:
JavaInput
A
JavaInput is a sequence of JavaInput.Toks that cover the Java input. A JavaInput.Tok is
either a token (if isToken()), or a non-token, which is a comment (if
isComment()) or a newline (if isNewline()) or a maximal sequence of other whitespace
characters (if isSpaces()). Each JavaInput.Tok contains a sequence of characters, an
index (sequential starting at 0 for tokens and comments, else -1), and a
(0-origin) position in the input. The concatenation of the texts of all the JavaInput.Toks equals the input. Each Input ends with a token EOF JavaInput.Tok, with empty text.
A /* comment possibly contains newlines; a // comment does not contain the
terminating newline character, but is followed by a newline JavaInput.Tok.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturn theTok's0-based column number.intgetIndex()Return theTok's index.TheTok's original text (before processing escapes).intReturn theTok's0-based position.getText()TheTok's text.booleanIs theToka comment?booleanIs theToka javadoc comment?booleanIs theToka newline?booleanIs theToka "//" comment?booleanIs theToka "/*" comment?(package private) booleanisToken()com.sun.tools.javac.parser.Tokens.TokenKindkind()intlength()The length of theTok's original text.toString()
-
Field Details
-
index
private final int index -
originalText
-
text
-
position
private final int position -
columnI
private final int columnI -
isToken
private final boolean isToken -
kind
private final com.sun.tools.javac.parser.Tokens.TokenKind kind
-
-
Constructor Details
-
Tok
Tok(int index, String originalText, String text, int position, int columnI, boolean isToken, com.sun.tools.javac.parser.Tokens.TokenKind kind) TheTokconstructor.- Parameters:
index- its indexoriginalText- its original text, before removing Unicode escapestext- its text after removing Unicode escapesposition- its0-origin position in the inputcolumnI- its0-origin column number in the inputisToken- whether theTokis a tokenkind- the token kind
-
-
Method Details
-
getIndex
public int getIndex()Description copied from interface:Input.TokReturn theTok's index. -
getText
Description copied from interface:Input.TokTheTok's text. -
getOriginalText
Description copied from interface:Input.TokTheTok's original text (before processing escapes).- Specified by:
getOriginalTextin interfaceInput.Tok
-
length
public int length()Description copied from interface:Input.TokThe length of theTok's original text. -
getPosition
public int getPosition()Description copied from interface:Input.TokReturn theTok's0-based position.- Specified by:
getPositionin interfaceInput.Tok- Returns:
- its position
-
getColumn
public int getColumn()Description copied from interface:Input.TokReturn theTok's0-based column number. -
isToken
boolean isToken() -
isNewline
public boolean isNewline()Description copied from interface:Input.TokIs theToka newline? -
isSlashSlashComment
public boolean isSlashSlashComment()Description copied from interface:Input.TokIs theToka "//" comment?- Specified by:
isSlashSlashCommentin interfaceInput.Tok
-
isSlashStarComment
public boolean isSlashStarComment()Description copied from interface:Input.TokIs theToka "/*" comment?- Specified by:
isSlashStarCommentin interfaceInput.Tok
-
isJavadocComment
public boolean isJavadocComment()Description copied from interface:Input.TokIs theToka javadoc comment?- Specified by:
isJavadocCommentin interfaceInput.Tok
-
isComment
public boolean isComment()Description copied from interface:Input.TokIs theToka comment? -
toString
-
kind
public com.sun.tools.javac.parser.Tokens.TokenKind kind()
-