Package com.palantir.javaformat.java
Interface FormatterService
public interface FormatterService
A stable facade for palantir-java-format. The implementation must be ServiceLoaded, to ensure its classpath remains
isolated.
-
Method Summary
Modifier and TypeMethodDescriptionFormats an input string (a Java compilation unit), reflows strings and fixes imports.com.google.common.collect.ImmutableList<Replacement>getFormatReplacements(String input, Collection<com.google.common.collect.Range<Integer>> ranges) Emit a list ofReplacements to convert from input to formatted output.
-
Method Details
-
getFormatReplacements
com.google.common.collect.ImmutableList<Replacement> getFormatReplacements(String input, Collection<com.google.common.collect.Range<Integer>> ranges) throws FormatterException Emit a list ofReplacements to convert from input to formatted output.- Parameters:
input- the input compilation unitranges- the character ranges to reformat- Returns:
- a list of
Replacements, sorted from low index to high index, without overlaps - Throws:
FormatterException- if the input string cannot be parsed
-
formatSourceReflowStringsAndFixImports
Formats an input string (a Java compilation unit), reflows strings and fixes imports.Fixing imports includes ordering, spacing, and removal of unused import statements.
- Parameters:
input- the input string- Returns:
- the output string
- Throws:
FormatterException- if the input string cannot be parsed- See Also:
-