Package com.google.googlejavaformat.java
Class JavaOutput
java.lang.Object
com.google.googlejavaformat.InputOutput
com.google.googlejavaformat.Output
com.google.googlejavaformat.java.JavaOutput
JavaOutput extends Output to represent a Java output document. It includes
methods to emit the output document.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.googlejavaformat.Output
Output.BreakTag -
Field Summary
Fields inherited from class com.google.googlejavaformat.InputOutput
EMPTY_RANGE, ranges -
Constructor Summary
ConstructorsConstructorDescriptionJavaOutput(String lineSeparator, Input javaInput, CommentsHelper commentsHelper) JavaOutputconstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidOutput a string.static StringapplyReplacements(String input, List<Replacement> replacements) voidblankLine(int k, OpsBuilder.BlankLineWanted wanted) A blank line is or is not wanted here.static Input.TokendTok(Input.Token token) The last non-whitespace Tok in the Token.voidflush()Flush any incomplete last line, then add the EOF token into our data structures.Get theCommentsHelper.com.google.common.collect.ImmutableList<Replacement>getFormatReplacements(com.google.common.collect.RangeSet<Integer> iRangeSet0) Emit a list ofReplacements to convert from input to output.voidindent(int indent) Indent by outputtingindentspaces.voidmarkForPartialFormat(Input.Token start, Input.Token end) Marks a region that can be partially formatted.static intstartPosition(Input.Token token) The earliest position of any Tok in the Token, including leading whitespace.static Input.TokstartTok(Input.Token token) The earliest non-whitespace Tok in the Token.toString()Methods inherited from class com.google.googlejavaformat.InputOutput
computeRanges, getLine, getLineCount, getRanges, makeKToIJ, setLines
-
Constructor Details
-
JavaOutput
JavaOutputconstructor.- Parameters:
javaInput- theInput, used to match up blank lines in the outputcommentsHelper- theCommentsHelper, used to rewrite comments
-
-
Method Details
-
blankLine
Description copied from class:OutputA blank line is or is not wanted here. -
markForPartialFormat
Description copied from class:OutputMarks a region that can be partially formatted.- Specified by:
markForPartialFormatin classOutput
-
append
Description copied from class:OutputOutput a string. -
indent
public void indent(int indent) Description copied from class:OutputIndent by outputtingindentspaces. -
flush
public void flush()Flush any incomplete last line, then add the EOF token into our data structures. -
getCommentsHelper
Description copied from class:OutputGet theCommentsHelper.- Specified by:
getCommentsHelperin classOutput- Returns:
- the
CommentsHelper
-
getFormatReplacements
public com.google.common.collect.ImmutableList<Replacement> getFormatReplacements(com.google.common.collect.RangeSet<Integer> iRangeSet0) Emit a list ofReplacements to convert from input to output.- Returns:
- a list of
Replacements, sorted by start index, without overlaps
-
applyReplacements
-
startPosition
The earliest position of any Tok in the Token, including leading whitespace. -
startTok
The earliest non-whitespace Tok in the Token. -
endTok
The last non-whitespace Tok in the Token. -
toString
-