Class AutoFormatService

java.lang.Object
org.openrewrite.java.service.AutoFormatService

@Incubating(since="8.2.0") public class AutoFormatService extends Object
  • Constructor Details

    • AutoFormatService

      public AutoFormatService()
  • Method Details

    • autoFormatVisitor

      public <P> JavaVisitor<P> autoFormatVisitor(@Nullable org.openrewrite.Tree stopAfter)
    • normalizeFormatVisitor

      public <P> JavaVisitor<P> normalizeFormatVisitor(@Nullable org.openrewrite.Tree stopAfter)
      Returns the language-appropriate NormalizeFormatVisitor. Edit recipes that mutate an LST node — e.g. by removing a leading annotation — can leave whitespace stranded on inner elements (modifier/kind prefixes), violating the "whitespace lives on the outermost element" convention. Running this visitor on the result moves the whitespace back to the outermost element so downstream passes (BlankLinesVisitor in particular) can normalize it.
    • blankLinesVisitor

      public <P> JavaVisitor<P> blankLinesVisitor(org.openrewrite.SourceFile sourceFile, @Nullable org.openrewrite.Tree stopAfter)
      Returns the language-appropriate BlankLinesVisitor.