Interface FormatterService


public interface FormatterService
A stable facade for palantir-java-format. The implementation must be ServiceLoaded, to ensure its classpath remains isolated.
  • 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 of Replacements to convert from input to formatted output.
      Parameters:
      input - the input compilation unit
      ranges - 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

      String formatSourceReflowStringsAndFixImports(String input) throws FormatterException
      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: