public final class JavaInput extends Input
JavaInput extends Input to represent a Java input document.
  • Constructor Details

  • Method Details

    • getText

      public String getText()
      Get the input text.
      Specified by:
      getText in class Input
      Returns:
      the input text
    • getPositionToColumnMap

      public ImmutableMap<Integer,Integer> getPositionToColumnMap()
      Specified by:
      getPositionToColumnMap in class Input
    • getkN

      public int getkN()
      Get the number of toks.
      Specified by:
      getkN in class Input
      Returns:
      the number of toks, excluding the EOF tok
    • getToken

      public com.google.googlejavaformat.java.JavaInput.Token getToken(int k)
      Get the Token by index.
      Specified by:
      getToken in class Input
      Parameters:
      k - the Tok index
    • getTokens

      public ImmutableList<? extends Input.Token> getTokens()
      Get the input tokens.
      Specified by:
      getTokens in class Input
      Returns:
      the input tokens
    • getPositionTokenMap

      public ImmutableRangeMap<Integer,com.google.googlejavaformat.java.JavaInput.Token> getPositionTokenMap()
      Get the navigable map from position to JavaInput.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 class Input
      Returns:
      the navigable map from position to JavaInput.Token
    • toString

      public String toString()
      Overrides:
      toString in class Input
    • 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 class Input
    • 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 class Input
    • 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