Package com.google.googlejavaformat.java
Class SnippetFormatter
- java.lang.Object
-
- com.google.googlejavaformat.java.SnippetFormatter
-
public class SnippetFormatter extends java.lang.ObjectFormats a subset of a compilation unit.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnippetFormatter.SnippetKindThe kind of snippet to format.private classSnippetFormatter.SnippetWrapper
-
Field Summary
Fields Modifier and Type Field Description private Formatterformatterprivate static intINDENTATION_SIZEprivate static com.google.common.base.CharMatcherNOT_WHITESPACE
-
Constructor Summary
Constructors Constructor Description SnippetFormatter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcreateIndentationString(int indentationLevel)com.google.common.collect.ImmutableList<Replacement>format(SnippetFormatter.SnippetKind kind, java.lang.String source, java.util.List<com.google.common.collect.Range<java.lang.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<java.lang.Integer>offsetRange(com.google.common.collect.Range<java.lang.Integer> range, int offset)private static java.util.List<com.google.common.collect.Range<java.lang.Integer>>offsetRanges(java.util.List<com.google.common.collect.Range<java.lang.Integer>> ranges, int offset)private SnippetFormatter.SnippetWrappersnippetWrapper(SnippetFormatter.SnippetKind kind, java.lang.String source, int initialIndent)private static java.util.List<Replacement>toReplacements(java.lang.String source, java.lang.String replacement)GeneratesReplacements rewritingsourcetoreplacement, under the assumption that they differ in whitespace alone.
-
-
-
Field Detail
-
INDENTATION_SIZE
private static final int INDENTATION_SIZE
- See Also:
- Constant Field Values
-
formatter
private final Formatter formatter
-
NOT_WHITESPACE
private static final com.google.common.base.CharMatcher NOT_WHITESPACE
-
-
Method Detail
-
createIndentationString
public java.lang.String createIndentationString(int indentationLevel)
-
offsetRange
private static com.google.common.collect.Range<java.lang.Integer> offsetRange(com.google.common.collect.Range<java.lang.Integer> range, int offset)
-
offsetRanges
private static java.util.List<com.google.common.collect.Range<java.lang.Integer>> offsetRanges(java.util.List<com.google.common.collect.Range<java.lang.Integer>> ranges, int offset)
-
format
public com.google.common.collect.ImmutableList<Replacement> format(SnippetFormatter.SnippetKind kind, java.lang.String source, java.util.List<com.google.common.collect.Range<java.lang.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
private static java.util.List<Replacement> toReplacements(java.lang.String source, java.lang.String replacement)
GeneratesReplacements rewritingsourcetoreplacement, under the assumption that they differ in whitespace alone.
-
snippetWrapper
private SnippetFormatter.SnippetWrapper snippetWrapper(SnippetFormatter.SnippetKind kind, java.lang.String source, int initialIndent)
-
-