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
static final class JavaInput.Tok extends java.lang.Object implements Input.Tok
AJavaInputis a sequence ofJavaInput.Toks that cover the Java input. AJavaInput.Tokis either a token (ifisToken()), or a non-token, which is a comment (ifisComment()) or a newline (ifisNewline()) or a maximal sequence of other whitespace characters (ifisSpaces()). EachJavaInput.Tokcontains a sequence of characters, an index (sequential starting at0for tokens and comments, else-1), and a (0-origin) position in the input. The concatenation of the texts of all theJavaInput.Toks equals the input. Each Input ends with a token EOFJavaInput.Tok, with empty text.A
/*comment possibly contains newlines; a//comment does not contain the terminating newline character, but is followed by a newlineJavaInput.Tok.
-
-
Constructor Summary
Constructors Constructor Description Tok(int index, java.lang.String originalText, java.lang.String text, int position, int columnI, boolean isToken, com.sun.tools.javac.parser.Tokens.TokenKind kind)TheTokconstructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumn()Return theTok's0-based column number.intgetIndex()Return theTok's index.java.lang.StringgetOriginalText()TheTok's original text (before processing escapes).intgetPosition()Return theTok's0-based position.java.lang.StringgetText()TheTok's text.booleanisComment()Is theToka comment?booleanisJavadocComment()Is theToka javadoc comment?booleanisNewline()Is theToka newline?booleanisSlashSlashComment()Is theToka "//" comment?booleanisSlashStarComment()Is theToka "/*" comment?(package private) booleanisToken()com.sun.tools.javac.parser.Tokens.TokenKindkind()intlength()The length of theTok's original text.java.lang.StringtoString()
-
-
-
Field Detail
-
index
private final int index
-
originalText
private final java.lang.String originalText
-
text
private final java.lang.String 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 Detail
-
Tok
Tok(int index, java.lang.String originalText, java.lang.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 Detail
-
getIndex
public int getIndex()
Description copied from interface:Input.TokReturn theTok's index.
-
getText
public java.lang.String getText()
Description copied from interface:Input.TokTheTok's text.
-
getOriginalText
public java.lang.String 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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
kind
public com.sun.tools.javac.parser.Tokens.TokenKind kind()
-
-