Package com.google.googlejavaformat.java
Class JavaInput
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 TypeMethodDescriptioncom.google.common.collect.RangeSet<Integer>characterRangesToTokenRanges(Collection<com.google.common.collect.Range<Integer>> characterRanges) intgetColumnNumber(int inputPosition) Converts a character offset in the input to a 0-based column number.intgetkN()Get the number of toks.intgetLineNumber(int inputPosition) Converts a character offset in the input to a line number.com.google.common.collect.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.TokengetToken(int k) Get the Token by index.com.google.common.collect.ImmutableList<? extends Input.Token>Get the input tokens.voidsetCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit unit) toString()Methods inherited from class com.google.googlejavaformat.Input
createDiagnosticMethods 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:
getPositionToColumnMapin 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 com.google.common.collect.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:
getPositionTokenMapin classInput- Returns:
- the navigable map from position to
JavaInput.Token
-
toString
-
getLineNumber
public int getLineNumber(int inputPosition) Description copied from class:InputConverts a character offset in the input to a line number.- Specified by:
getLineNumberin classInput
-
getColumnNumber
public int getColumnNumber(int inputPosition) Description copied from class:InputConverts a character offset in the input to a 0-based column number.- Specified by:
getColumnNumberin classInput
-
setCompilationUnit
public void setCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit unit) -
characterRangesToTokenRanges
public com.google.common.collect.RangeSet<Integer> characterRangesToTokenRanges(Collection<com.google.common.collect.Range<Integer>> characterRanges) throws FormatterException - Throws:
FormatterException
-