Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: add formatter option to use Java17InputAstVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Oct 22, 2023
1 parent f1207d2 commit f61b150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOExcept
OpsBuilder builder = new OpsBuilder(javaInput, javaOutput);
// Output the compilation unit.
JavaInputAstVisitor visitor;
if (Runtime.version().feature() >= 17) {
if (options.useJava17AstVisitor()) {
try {
visitor =
Class.forName("com.google.googlejavaformat.java.java17.Java17InputAstVisitor")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public int indentationMultiplier() {

public abstract boolean reorderModifiers();

public abstract boolean useJava17AstVisitor();

/** Returns the code style. */
public abstract Style style();

Expand All @@ -71,7 +73,8 @@ public static Builder builder() {
return new AutoValue_JavaFormatterOptions.Builder()
.style(Style.GOOGLE)
.formatJavadoc(true)
.reorderModifiers(true);
.reorderModifiers(true)
.useJava17AstVisitor(true);
}

/** A builder for {@link JavaFormatterOptions}. */
Expand All @@ -84,6 +87,8 @@ public abstract static class Builder {

public abstract Builder reorderModifiers(boolean reorderModifiers);

public abstract Builder useJava17AstVisitor(boolean reorderModifiers);

public abstract JavaFormatterOptions build();
}
}
}

0 comments on commit f61b150

Please sign in to comment.