Package com.google.googlejavaformat.java
Class ModifierOrderer
java.lang.Object
com.google.googlejavaformat.java.ModifierOrderer
Fixes sequences of modifiers to be in JLS order.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA class that contains the tokens corresponding to a modifier. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddTrivia(StringBuilder replacement, com.google.common.collect.ImmutableList<? extends Input.Tok> toks) private static JavaInputapplyReplacements(JavaInput javaInput, com.google.common.collect.TreeRangeMap<Integer, String> replacementMap) Applies replacements to the given string.private static @Nullable ModifierasModifier(com.google.common.collect.ImmutableList<Input.Token> tokens) private static @Nullable ModifierasModifier(Input.Token token) Returns the given token as aModifier, ornullif it is not a modifier.private static @Nullable ModifierOrderer.ModifierTokensgetModifierTokens(Iterator<? extends Input.Token> it) (package private) static JavaInputreorderModifiers(JavaInput javaInput, Collection<com.google.common.collect.Range<Integer>> characterRanges) Reorders all modifiers in the given text and within the given character ranges to be in JLS order.(package private) static JavaInputreorderModifiers(String text) Reorders all modifiers in the given text to be in JLS order.
-
Constructor Details
-
ModifierOrderer
ModifierOrderer()
-
-
Method Details
-
reorderModifiers
Reorders all modifiers in the given text to be in JLS order.- Throws:
FormatterException
-
reorderModifiers
static JavaInput reorderModifiers(JavaInput javaInput, Collection<com.google.common.collect.Range<Integer>> characterRanges) throws FormatterException Reorders all modifiers in the given text and within the given character ranges to be in JLS order.- Throws:
FormatterException
-
addTrivia
private static void addTrivia(StringBuilder replacement, com.google.common.collect.ImmutableList<? extends Input.Tok> toks) -
getModifierTokens
private static @Nullable ModifierOrderer.ModifierTokens getModifierTokens(Iterator<? extends Input.Token> it) -
asModifier
private static @Nullable Modifier asModifier(com.google.common.collect.ImmutableList<Input.Token> tokens) -
asModifier
Returns the given token as aModifier, ornullif it is not a modifier. -
applyReplacements
private static JavaInput applyReplacements(JavaInput javaInput, com.google.common.collect.TreeRangeMap<Integer, String> replacementMap) throws FormatterExceptionApplies replacements to the given string.- Throws:
FormatterException
-