public final class JavaOutput extends Output
JavaOutput extends Output to represent a Java output document. It includes methods to emit the output document.
  • Constructor Details

    • JavaOutput

      public JavaOutput(String lineSeparator, Input javaInput, CommentsHelper commentsHelper)
      JavaOutput constructor.
      Parameters:
      javaInput - the Input, used to match up blank lines in the output
      commentsHelper - the CommentsHelper, used to rewrite comments
  • Method Details

    • blankLine

      public void blankLine(int k, OpsBuilder.BlankLineWanted wanted)
      Description copied from class: Output
      A blank line is or is not wanted here.
      Specified by:
      blankLine in class Output
      Parameters:
      k - the Input.Tok index
      wanted - whether a blank line is wanted here
    • markForPartialFormat

      public void markForPartialFormat(Input.Token start, Input.Token end)
      Description copied from class: Output
      Marks a region that can be partially formatted.
      Specified by:
      markForPartialFormat in class Output
    • append

      public void append(String text, Range<Integer> range)
      Description copied from class: Output
      Output a string.
      Specified by:
      append in class Output
      Parameters:
      text - the string
      range - the Range corresponding to the string
    • indent

      public void indent(int indent)
      Description copied from class: Output
      Indent by outputting indent spaces.
      Specified by:
      indent in class Output
      Parameters:
      indent - the current indent
    • flush

      public void flush()
      Flush any incomplete last line, then add the EOF token into our data structures.
    • getCommentsHelper

      public CommentsHelper getCommentsHelper()
      Description copied from class: Output
      Specified by:
      getCommentsHelper in class Output
      Returns:
      the CommentsHelper
    • getFormatReplacements

      public ImmutableList<Replacement> getFormatReplacements(RangeSet<Integer> iRangeSet0)
      Emit a list of Replacements to convert from input to output.
      Returns:
      a list of Replacements, sorted by start index, without overlaps
    • applyReplacements

      public static String applyReplacements(String input, List<Replacement> replacements)
    • startPosition

      public static int startPosition(Input.Token token)
      The earliest position of any Tok in the Token, including leading whitespace.
    • startTok

      public static Input.Tok startTok(Input.Token token)
      The earliest non-whitespace Tok in the Token.
    • endTok

      public static Input.Tok endTok(Input.Token token)
      The last non-whitespace Tok in the Token.
    • toString

      public String toString()
      Overrides:
      toString in class Output