java.lang.Object
com.google.googlejavaformat.InputOutput
com.google.googlejavaformat.Input
com.google.googlejavaformat.java.JavaInput
JavaInput
extends Input
to represent a Java input document.-
Field Summary
Fields inherited from class com.google.googlejavaformat.InputOutput
EMPTY_RANGE, ranges
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharacterRangesToTokenRanges
(Collection<Range<Integer>> characterRanges) int
getColumnNumber
(int inputPosition) Converts a character offset in the input to a 0-based column number.int
getkN()
Get the number of toks.int
getLineNumber
(int inputPosition) Converts a character offset in the input to a line number.ImmutableRangeMap
<Integer, com.google.googlejavaformat.java.JavaInput.Token> Get the navigable map from position toJavaInput.Token
.getText()
Get the input text.com.google.googlejavaformat.java.JavaInput.Token
getToken
(int k) Get the Token by index.ImmutableList
<? extends Input.Token> Get the input tokens.void
setCompilationUnit
(com.sun.tools.javac.tree.JCTree.JCCompilationUnit unit) toString()
Methods inherited from class com.google.googlejavaformat.Input
createDiagnostic
Methods inherited from class com.google.googlejavaformat.InputOutput
computeRanges, getLine, getLineCount, getRanges, makeKToIJ, setLines
-
Constructor Details
-
JavaInput
Input constructor.- Parameters:
text
- the input text- Throws:
FormatterException
- if the input cannot be parsed
-
-
Method Details
-
getText
Get the input text. -
getPositionToColumnMap
- Specified by:
getPositionToColumnMap
in classInput
-
getkN
public int getkN()Get the number of toks. -
getToken
public com.google.googlejavaformat.java.JavaInput.Token getToken(int k) Get the Token by index. -
getTokens
Get the input tokens. -
getPositionTokenMap
public ImmutableRangeMap<Integer,com.google.googlejavaformat.java.JavaInput.Token> getPositionTokenMap()Get the navigable map from position toJavaInput.Token
. Used to look for tokens following a given one, and to implement the --offset and --length flags to reformat a character range in the input file.- Specified by:
getPositionTokenMap
in classInput
- Returns:
- the navigable map from position to
JavaInput.Token
-
toString
-
getLineNumber
public int getLineNumber(int inputPosition) Description copied from class:Input
Converts a character offset in the input to a line number.- Specified by:
getLineNumber
in classInput
-
getColumnNumber
public int getColumnNumber(int inputPosition) Description copied from class:Input
Converts a character offset in the input to a 0-based column number.- Specified by:
getColumnNumber
in classInput
-
setCompilationUnit
public void setCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit unit) -
characterRangesToTokenRanges
public RangeSet<Integer> characterRangesToTokenRanges(Collection<Range<Integer>> characterRanges) throws FormatterException - Throws:
FormatterException
-