Package com.google.googlejavaformat
Class Input
- java.lang.Object
-
- com.google.googlejavaformat.InputOutput
-
- com.google.googlejavaformat.Input
-
- Direct Known Subclasses:
JavaInput
public abstract class Input extends InputOutput
An input to the formatter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceInput.TokATok("tock") is a token, or a comment, or a newline, or a maximal string of blanks.static interfaceInput.TokenATokenis a language-level token.
-
Field Summary
-
Fields inherited from class com.google.googlejavaformat.InputOutput
EMPTY_RANGE, ranges
-
-
Constructor Summary
Constructors Constructor Description Input()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FormatterDiagnosticcreateDiagnostic(int inputPosition, java.lang.String message)Construct a diagnostic.abstract intgetColumnNumber(int inputPosition)Converts a character offset in the input to a 0-based column number.abstract intgetkN()Get the number of toks.abstract intgetLineNumber(int inputPosition)Converts a character offset in the input to a line number.abstract com.google.common.collect.ImmutableMap<java.lang.Integer,java.lang.Integer>getPositionToColumnMap()abstract com.google.common.collect.ImmutableRangeMap<java.lang.Integer,? extends Input.Token>getPositionTokenMap()A map from [start, end] position ranges toInput.Tokens.abstract java.lang.StringgetText()abstract Input.TokengetToken(int k)Get the Token by index.abstract com.google.common.collect.ImmutableList<? extends Input.Token>getTokens()Get the input tokens.java.lang.StringtoString()-
Methods inherited from class com.google.googlejavaformat.InputOutput
computeRanges, getLine, getLineCount, getRanges, makeKToIJ, setLines
-
-
-
-
Method Detail
-
getTokens
public abstract com.google.common.collect.ImmutableList<? extends Input.Token> getTokens()
Get the input tokens.- Returns:
- the input tokens
-
getPositionTokenMap
public abstract com.google.common.collect.ImmutableRangeMap<java.lang.Integer,? extends Input.Token> getPositionTokenMap()
A map from [start, end] position ranges toInput.Tokens.
-
getPositionToColumnMap
public abstract com.google.common.collect.ImmutableMap<java.lang.Integer,java.lang.Integer> getPositionToColumnMap()
-
getText
public abstract java.lang.String getText()
-
getkN
public abstract int getkN()
Get the number of toks.- Returns:
- the number of toks, excluding the EOF tok
-
getToken
public abstract Input.Token getToken(int k)
Get the Token by index.- Parameters:
k- the Tok index
-
toString
public java.lang.String toString()
- Overrides:
toStringin classInputOutput
-
getLineNumber
public abstract int getLineNumber(int inputPosition)
Converts a character offset in the input to a line number.
-
getColumnNumber
public abstract int getColumnNumber(int inputPosition)
Converts a character offset in the input to a 0-based column number.
-
createDiagnostic
public FormatterDiagnostic createDiagnostic(int inputPosition, java.lang.String message)
Construct a diagnostic. Populates the input filename, and converts character offsets to numbers.
-
-