Package com.google.googlejavaformat.java
Class SnippetFormatter
java.lang.Object
com.google.googlejavaformat.java.SnippetFormatter
Formats a subset of a compilation unit.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe kind of snippet to format.private class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Formatterprivate static final intprivate static final com.google.common.base.CharMatcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateIndentationString(int indentationLevel) com.google.common.collect.ImmutableList<Replacement> format(SnippetFormatter.SnippetKind kind, String source, List<com.google.common.collect.Range<Integer>> ranges, int initialIndent, boolean includeComments) Runs the Google Java formatter on the given source, with only the given ranges specified.private static com.google.common.collect.Range<Integer> offsetRange(com.google.common.collect.Range<Integer> range, int offset) offsetRanges(List<com.google.common.collect.Range<Integer>> ranges, int offset) private SnippetFormatter.SnippetWrappersnippetWrapper(SnippetFormatter.SnippetKind kind, String source, int initialIndent) private static List<Replacement> toReplacements(String source, String replacement) GeneratesReplacements rewritingsourcetoreplacement, under the assumption that they differ in whitespace alone.
-
Field Details
-
INDENTATION_SIZE
private static final int INDENTATION_SIZE- See Also:
-
formatter
-
NOT_WHITESPACE
private static final com.google.common.base.CharMatcher NOT_WHITESPACE
-
-
Constructor Details
-
SnippetFormatter
public SnippetFormatter()
-
-
Method Details
-
createIndentationString
-
offsetRange
-
offsetRanges
-
format
public com.google.common.collect.ImmutableList<Replacement> format(SnippetFormatter.SnippetKind kind, String source, List<com.google.common.collect.Range<Integer>> ranges, int initialIndent, boolean includeComments) throws FormatterException Runs the Google Java formatter on the given source, with only the given ranges specified.- Throws:
FormatterException
-
toReplacements
GeneratesReplacements rewritingsourcetoreplacement, under the assumption that they differ in whitespace alone. -
snippetWrapper
private SnippetFormatter.SnippetWrapper snippetWrapper(SnippetFormatter.SnippetKind kind, String source, int initialIndent)
-