From b1dce94186e290358b74f42418b5e43119ef723c Mon Sep 17 00:00:00 2001 From: Michael Plump Date: Thu, 11 Jan 2024 13:37:05 -0800 Subject: [PATCH 01/31] Update the IntelliJ plugin to gfj 1.19.2. PiperOrigin-RevId: 597641894 --- idea_plugin/build.gradle.kts | 6 +++--- idea_plugin/src/main/resources/META-INF/plugin.xml | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/idea_plugin/build.gradle.kts b/idea_plugin/build.gradle.kts index 5e965823f..2247893c1 100644 --- a/idea_plugin/build.gradle.kts +++ b/idea_plugin/build.gradle.kts @@ -14,7 +14,7 @@ * limitations under the License. */ -plugins { id("org.jetbrains.intellij") version "1.15.0" } +plugins { id("org.jetbrains.intellij") version "1.16.1" } apply(plugin = "org.jetbrains.intellij") @@ -22,7 +22,7 @@ apply(plugin = "java") repositories { mavenCentral() } -val googleJavaFormatVersion = "1.17.0" +val googleJavaFormatVersion = "1.19.2" java { sourceCompatibility = JavaVersion.VERSION_11 @@ -62,5 +62,5 @@ tasks { dependencies { implementation("com.google.googlejavaformat:google-java-format:${googleJavaFormatVersion}") testImplementation("junit:junit:4.13.2") - testImplementation("com.google.truth:truth:1.1.5") + testImplementation("com.google.truth:truth:1.2.0") } diff --git a/idea_plugin/src/main/resources/META-INF/plugin.xml b/idea_plugin/src/main/resources/META-INF/plugin.xml index 1b1e67ffa..a5600b00d 100644 --- a/idea_plugin/src/main/resources/META-INF/plugin.xml +++ b/idea_plugin/src/main/resources/META-INF/plugin.xml @@ -35,6 +35,8 @@ ]]> +
1.19.2.0
+
Updated to use google-java-format 1.19.2.
1.17.0.0
Updated to use google-java-format 1.17.0.
Fixed "Document is locked" errors (Thanks, @facboy!)
From 412d761b687629df55cadef6ba1f846dee48a6d5 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Wed, 24 Jan 2024 15:24:53 -0800 Subject: [PATCH 02/31] Fix a test bug introduced by https://github.com/google/google-java-format/commit/430ba3b0e237b746157a3392663da4b4bb7c733d PiperOrigin-RevId: 601252048 --- .../googlejavaformat/java/FormatterIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java b/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java index 5fb356750..26493b022 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java @@ -104,10 +104,9 @@ public static Iterable data() throws IOException { String expectedOutput = outputs.get(fileName); Optional version = VERSIONED_TESTS.inverse().get(fileName).stream().collect(toOptional()); - if (Runtime.version().feature() < version.orElse(Integer.MAX_VALUE)) { - continue; + if (Runtime.version().feature() >= version.orElse(Integer.MIN_VALUE)) { + testInputs.add(new Object[] {fileName, input, expectedOutput}); } - testInputs.add(new Object[] {fileName, input, expectedOutput}); } return testInputs; } From 03efe44d9affc989eee8623651fbdf1bcc7240dc Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 26 Jan 2024 10:20:00 -0800 Subject: [PATCH 03/31] Keep type-use annotation with type when wrapping PiperOrigin-RevId: 601800310 --- .../java/JavaInputAstVisitor.java | 18 ++++++++++++++---- .../java/testdata/B322210626.input | 11 +++++++++++ .../java/testdata/B322210626.output | 11 +++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.input create mode 100644 core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.output diff --git a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java index 8914c8ea2..1f51a7632 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java @@ -1407,6 +1407,14 @@ public Void visitMethod(MethodTree node, Void unused) { annotations, Direction.VERTICAL, /* declarationAnnotationBreak= */ Optional.empty()); + if (node.getTypeParameters().isEmpty() && node.getReturnType() != null) { + // If there are type parameters, we use a heuristic above to format annotations after the + // type parameter declarations as type-use annotations. If there are no type parameters, + // use the heuristics in visitModifiers for recognizing well known type-use annotations and + // formatting them as annotations on the return type. + returnTypeAnnotations = typeAnnotations; + typeAnnotations = ImmutableList.of(); + } Tree baseReturnType = null; Deque> dims = null; @@ -1436,10 +1444,6 @@ public Void visitMethod(MethodTree node, Void unused) { } token("<"); typeParametersRest(node.getTypeParameters(), plusFour); - if (!returnTypeAnnotations.isEmpty()) { - builder.breakToFill(" "); - visitAnnotations(returnTypeAnnotations, BreakOrNot.NO, BreakOrNot.NO); - } first = false; } @@ -1456,8 +1460,14 @@ public Void visitMethod(MethodTree node, Void unused) { builder.open(make(breakBeforeType, plusFour, ZERO)); openedNameAndTypeScope = true; } + builder.open(ZERO); + if (!returnTypeAnnotations.isEmpty()) { + visitAnnotations(returnTypeAnnotations, BreakOrNot.NO, BreakOrNot.NO); + builder.breakOp(" "); + } scan(baseReturnType, null); maybeAddDims(dims); + builder.close(); } if (!first) { builder.breakOp(Doc.FillMode.INDEPENDENT, " ", ZERO, Optional.of(breakBeforeName)); diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.input b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.input new file mode 100644 index 000000000..931a7d726 --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.input @@ -0,0 +1,11 @@ +class WrapTypeUse { + public static final @Nullable + WrapTypeUse get() { + return null; + } + + public @Nullable + Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx getXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx() { + return null; + } +} diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.output b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.output new file mode 100644 index 000000000..b34bdb38c --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B322210626.output @@ -0,0 +1,11 @@ +class WrapTypeUse { + public static final + @Nullable WrapTypeUse get() { + return null; + } + + public @Nullable Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + getXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx() { + return null; + } +} From a110c89f698886fe90f4f7139b23c84e0f963312 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 26 Jan 2024 10:54:24 -0800 Subject: [PATCH 04/31] Rename `first` to `afterFirstToken` See unknown commit PiperOrigin-RevId: 601810198 --- .../java/JavaInputAstVisitor.java | 214 +++++++++--------- .../java/java17/Java17InputAstVisitor.java | 16 +- .../java/java21/Java21InputAstVisitor.java | 6 +- 3 files changed, 119 insertions(+), 117 deletions(-) diff --git a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java index 1f51a7632..1123ac01c 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java @@ -368,16 +368,16 @@ public Void scan(Tree tree, Void unused) { @Override public Void visitCompilationUnit(CompilationUnitTree node, Void unused) { - boolean first = true; + boolean afterFirstToken = false; if (node.getPackageName() != null) { markForPartialFormat(); visitPackage(node.getPackageName(), node.getPackageAnnotations()); builder.forcedBreak(); - first = false; + afterFirstToken = true; } dropEmptyDeclarations(); if (!node.getImports().isEmpty()) { - if (!first) { + if (afterFirstToken) { builder.blankLineWanted(BlankLineWanted.YES); } for (ImportTree importDeclaration : node.getImports()) { @@ -386,7 +386,7 @@ public Void visitCompilationUnit(CompilationUnitTree node, Void unused) { scan(importDeclaration, null); builder.forcedBreak(); } - first = false; + afterFirstToken = true; } dropEmptyDeclarations(); for (Tree type : node.getTypeDecls()) { @@ -395,22 +395,22 @@ public Void visitCompilationUnit(CompilationUnitTree node, Void unused) { // TODO(cushon): remove this if https://bugs.openjdk.java.net/browse/JDK-8027682 is fixed continue; } - if (!first) { + if (afterFirstToken) { builder.blankLineWanted(BlankLineWanted.YES); } markForPartialFormat(); scan(type, null); builder.forcedBreak(); - first = false; + afterFirstToken = true; dropEmptyDeclarations(); } - handleModule(first, node); + handleModule(afterFirstToken, node); // set a partial format marker at EOF to make sure we can format the entire file markForPartialFormat(); return null; } - protected void handleModule(boolean first, CompilationUnitTree node) {} + protected void handleModule(boolean afterFirstToken, CompilationUnitTree node) {} /** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */ protected void dropEmptyDeclarations() { @@ -514,9 +514,9 @@ public boolean visitArrayInitializer(List expressions) builder.open(plusTwo); token("{"); builder.forcedBreak(); - boolean first = true; + boolean afterFirstToken = false; for (Iterable row : Iterables.partition(expressions, cols)) { - if (!first) { + if (afterFirstToken) { builder.forcedBreak(); } builder.open(row.iterator().next().getKind() == NEW_ARRAY || cols == 1 ? ZERO : plusFour); @@ -531,7 +531,7 @@ public boolean visitArrayInitializer(List expressions) } builder.guessToken(","); builder.close(); - first = false; + afterFirstToken = true; } builder.breakOp(minusTwo); builder.close(); @@ -562,15 +562,15 @@ public boolean visitArrayInitializer(List expressions) if (allowFilledElementsOnOwnLine) { builder.open(ZERO); } - boolean first = true; + boolean afterFirstToken = false; FillMode fillMode = shortItems ? FillMode.INDEPENDENT : FillMode.UNIFIED; for (ExpressionTree expression : expressions) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(fillMode, " ", ZERO); } scan(expression, null); - first = false; + afterFirstToken = true; } builder.guessToken(","); if (allowFilledElementsOnOwnLine) { @@ -842,14 +842,14 @@ public boolean visitEnumDeclaration(ClassTree node) { token("implements"); builder.breakOp(" "); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; for (Tree superInterfaceType : node.getImplementsClause()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakToFill(" "); } scan(superInterfaceType, null); - first = false; + afterFirstToken = true; } builder.close(); builder.close(); @@ -893,16 +893,16 @@ public boolean visitEnumDeclaration(ClassTree node) { builder.blankLineWanted(BlankLineWanted.NO); builder.forcedBreak(); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; for (VariableTree enumConstant : enumConstants) { - if (!first) { + if (afterFirstToken) { token(","); builder.forcedBreak(); builder.blankLineWanted(BlankLineWanted.PRESERVE); } markForPartialFormat(); visitEnumConstantDeclaration(enumConstant); - first = false; + afterFirstToken = true; } if (builder.peekToken().orElse("").equals(",")) { token(","); @@ -984,18 +984,19 @@ void visitVariables( Optional.ofNullable(fragment.getInitializer()), Optional.of(";"), /* receiverExpression= */ Optional.empty(), - Optional.ofNullable(variableFragmentDims(true, 0, fragment.getType()))); + Optional.ofNullable(variableFragmentDims(false, 0, fragment.getType()))); } else { declareMany(fragments, annotationDirection); } } - private static TypeWithDims variableFragmentDims(boolean first, int leadingDims, Tree type) { + private static TypeWithDims variableFragmentDims( + boolean afterFirstToken, int leadingDims, Tree type) { if (type == null) { return null; } - if (first) { + if (!afterFirstToken) { return DimensionHelpers.extractDims(type, SortedDims.YES); } TypeWithDims dims = DimensionHelpers.extractDims(type, SortedDims.NO); @@ -1022,15 +1023,15 @@ public Void visitForLoop(ForLoopTree node, Void unused) { visitVariables( variableFragments(it, it.next()), DeclarationKind.NONE, Direction.HORIZONTAL); } else { - boolean first = true; + boolean afterFirstToken = false; builder.open(ZERO); for (StatementTree t : node.getInitializer()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(((ExpressionStatementTree) t).getExpression(), null); - first = false; + afterFirstToken = true; } token(";"); builder.close(); @@ -1087,11 +1088,11 @@ public Void visitIf(IfTree node, Void unused) { } } builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; boolean followingBlock = false; int expressionsN = expressions.size(); for (int i = 0; i < expressionsN; i++) { - if (!first) { + if (afterFirstToken) { if (followingBlock) { builder.space(); } else { @@ -1115,7 +1116,7 @@ public Void visitIf(IfTree node, Void unused) { AllowLeadingBlankLine.YES, AllowTrailingBlankLine.valueOf(trailingClauses)); followingBlock = statements.get(i).getKind() == BLOCK; - first = false; + afterFirstToken = true; } if (node.getElseStatement() != null) { if (followingBlock) { @@ -1208,15 +1209,15 @@ public Void visitInstanceOf(InstanceOfTree node, Void unused) { public Void visitIntersectionType(IntersectionTypeTree node, Void unused) { sync(node); builder.open(plusFour); - boolean first = true; + boolean afterFirstToken = false; for (Tree type : node.getBounds()) { - if (!first) { + if (afterFirstToken) { builder.breakToFill(" "); token("&"); builder.space(); } scan(type, null); - first = false; + afterFirstToken = true; } builder.close(); return null; @@ -1243,9 +1244,9 @@ public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) { if (parens) { token("("); } - boolean first = true; + boolean afterFirstToken = false; for (VariableTree parameter : node.getParameters()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } @@ -1253,7 +1254,7 @@ public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) { ImmutableList.of(parameter), DeclarationKind.NONE, fieldAnnotationDirection(parameter.getModifiers())); - first = false; + afterFirstToken = true; } if (parens) { token(")"); @@ -1295,14 +1296,14 @@ public Void visitAnnotation(AnnotationTree node, Void unused) { builder.open(plusFour); token("("); builder.breakOp(); - boolean first = true; + boolean afterFirstToken = false; // Format the member value pairs one-per-line if any of them are // initialized with arrays. boolean hasArrayInitializer = Iterables.any(node.getArguments(), JavaInputAstVisitor::isArrayValue); for (ExpressionTree argument : node.getArguments()) { - if (!first) { + if (afterFirstToken) { token(","); if (hasArrayInitializer) { builder.forcedBreak(); @@ -1315,7 +1316,7 @@ public Void visitAnnotation(AnnotationTree node, Void unused) { } else { scan(argument, null); } - first = false; + afterFirstToken = true; } token(")"); builder.close(); @@ -1433,28 +1434,28 @@ public Void visitMethod(MethodTree node, Void unused) { BreakTag breakBeforeType = genSym(); builder.open(ZERO); { - boolean first = true; + boolean afterFirstToken = false; if (!typeAnnotations.isEmpty()) { visitAnnotations(typeAnnotations, BreakOrNot.NO, BreakOrNot.NO); - first = false; + afterFirstToken = true; } if (!node.getTypeParameters().isEmpty()) { - if (!first) { + if (afterFirstToken) { builder.breakToFill(" "); } token("<"); typeParametersRest(node.getTypeParameters(), plusFour); - first = false; + afterFirstToken = true; } boolean openedNameAndTypeScope = false; // constructor-like declarations that don't match the name of the enclosing class are // parsed as method declarations with a null return type if (baseReturnType != null) { - if (!first) { + if (afterFirstToken) { builder.breakOp(INDEPENDENT, " ", ZERO, Optional.of(breakBeforeType)); } else { - first = false; + afterFirstToken = true; } if (!openedNameAndTypeScope) { builder.open(make(breakBeforeType, plusFour, ZERO)); @@ -1469,10 +1470,10 @@ public Void visitMethod(MethodTree node, Void unused) { maybeAddDims(dims); builder.close(); } - if (!first) { + if (afterFirstToken) { builder.breakOp(Doc.FillMode.INDEPENDENT, " ", ZERO, Optional.of(breakBeforeName)); } else { - first = false; + afterFirstToken = true; } if (!openedNameAndTypeScope) { builder.open(ZERO); @@ -1712,14 +1713,14 @@ public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) { token("<"); builder.breakOp(); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; for (Tree typeArgument : node.getTypeArguments()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(typeArgument, null); - first = false; + afterFirstToken = true; } builder.close(); builder.close(); @@ -1905,13 +1906,13 @@ protected void visitSwitch(ExpressionTree expression, List c tokenBreakTrailingComment("{", plusTwo); builder.blankLineWanted(BlankLineWanted.NO); builder.open(plusTwo); - boolean first = true; + boolean afterFirstToken = false; for (CaseTree caseTree : cases) { - if (!first) { + if (afterFirstToken) { builder.blankLineWanted(BlankLineWanted.PRESERVE); } scan(caseTree, null); - first = false; + afterFirstToken = true; } builder.close(); builder.forcedBreak(); @@ -1954,9 +1955,9 @@ public Void visitTry(TryTree node, Void unused) { if (!node.getResources().isEmpty()) { token("("); builder.open(node.getResources().size() > 1 ? plusFour : ZERO); - boolean first = true; + boolean afterFirstToken = false; for (Tree resource : node.getResources()) { - if (!first) { + if (afterFirstToken) { builder.forcedBreak(); } if (resource instanceof VariableTree) { @@ -1981,7 +1982,7 @@ public Void visitTry(TryTree node, Void unused) { token(";"); builder.space(); } - first = false; + afterFirstToken = true; } if (builder.peekToken().equals(Optional.of(";"))) { token(";"); @@ -2070,15 +2071,15 @@ public Void visitTypeParameter(TypeParameterTree node, Void unused) { builder.open(plusFour); builder.breakOp(" "); builder.open(plusFour); - boolean first = true; + boolean afterFirstToken = false; for (Tree typeBound : node.getBounds()) { - if (!first) { + if (afterFirstToken) { builder.breakToFill(" "); token("&"); builder.space(); } scan(typeBound, null); - first = false; + afterFirstToken = true; } builder.close(); builder.close(); @@ -2134,13 +2135,13 @@ protected void visitAnnotations( if (breakBefore.isYes()) { builder.breakToFill(" "); } - boolean first = true; + boolean afterFirstToken = false; for (AnnotationTree annotation : annotations) { - if (!first) { + if (afterFirstToken) { builder.breakToFill(" "); } scan(annotation, null); - first = false; + afterFirstToken = true; } if (breakAfter.isYes()) { builder.breakToFill(" "); @@ -2220,17 +2221,17 @@ private void visitStatement( } protected void visitStatements(List statements) { - boolean first = true; + boolean afterFirstToken = false; PeekingIterator it = Iterators.peekingIterator(statements.iterator()); dropEmptyDeclarations(); while (it.hasNext()) { StatementTree tree = it.next(); builder.forcedBreak(); - if (!first) { + if (afterFirstToken) { builder.blankLineWanted(BlankLineWanted.PRESERVE); } markForPartialFormat(); - first = false; + afterFirstToken = true; List fragments = variableFragments(it, tree); if (!fragments.isEmpty()) { visitVariables( @@ -2300,17 +2301,17 @@ private ImmutableList visitModifiers( Deque declarationModifiers = new ArrayDeque<>(splitModifiers.declarationModifiers()); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; boolean lastWasAnnotation = false; while (!declarationModifiers.isEmpty() && !declarationModifiers.peekFirst().isModifier()) { - if (!first) { + if (afterFirstToken) { builder.addAll( annotationsDirection.isVertical() ? forceBreakList(declarationAnnotationBreak) : breakList(declarationAnnotationBreak)); } formatAnnotationOrModifier(declarationModifiers); - first = false; + afterFirstToken = true; lastWasAnnotation = true; } builder.close(); @@ -2327,13 +2328,13 @@ private ImmutableList visitModifiers( } builder.open(ZERO); - first = true; + afterFirstToken = false; while (!declarationModifiers.isEmpty()) { - if (!first) { + if (afterFirstToken) { builder.addAll(breakFillList(Optional.empty())); } formatAnnotationOrModifier(declarationModifiers); - first = false; + afterFirstToken = true; } builder.close(); builder.addAll(breakFillList(Optional.empty())); @@ -2556,14 +2557,14 @@ private void visitUnionType(VariableTree declaration) { Direction.HORIZONTAL, /* declarationAnnotationBreak= */ Optional.empty()); List union = type.getTypeAlternatives(); - boolean first = true; + boolean afterFirstToken = false; for (int i = 0; i < union.size() - 1; i++) { - if (!first) { + if (afterFirstToken) { builder.breakOp(" "); token("|"); builder.space(); } else { - first = false; + afterFirstToken = true; } scan(union.get(i), null); } @@ -2612,7 +2613,7 @@ protected void visitFormals( return; } builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; if (receiver.isPresent()) { // TODO(user): Use builders. declareOne( @@ -2627,11 +2628,11 @@ protected void visitFormals( !parameters.isEmpty() ? Optional.of(",") : Optional.empty(), Optional.of(receiver.get().getNameExpression()), /* typeWithDims= */ Optional.empty()); - first = false; + afterFirstToken = true; } for (int i = 0; i < parameters.size(); i++) { VariableTree parameter = parameters.get(i); - if (!first) { + if (afterFirstToken) { builder.breakOp(" "); } visitToDeclare( @@ -2641,7 +2642,7 @@ protected void visitFormals( /* initializer= */ Optional.empty(), "=", i < parameters.size() - 1 ? Optional.of(",") : /* a= */ Optional.empty()); - first = false; + afterFirstToken = true; } builder.close(); } @@ -2650,14 +2651,14 @@ protected void visitFormals( private void visitThrowsClause(List thrownExceptionTypes) { token("throws"); builder.breakToFill(" "); - boolean first = true; + boolean afterFirstToken = false; for (ExpressionTree thrownExceptionType : thrownExceptionTypes) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(thrownExceptionType, null); - first = false; + afterFirstToken = true; } } @@ -2721,14 +2722,14 @@ private void visitDirective( builder.space(); token(separator); builder.forcedBreak(); - boolean first = true; + boolean afterFirstToken = false; for (ExpressionTree item : items) { - if (!first) { + if (afterFirstToken) { token(","); builder.forcedBreak(); } scan(item, null); - first = false; + afterFirstToken = true; } token(";"); builder.close(); @@ -2791,13 +2792,13 @@ private void visitName(Tree node) { stack.addFirst(((MemberSelectTree) node).getIdentifier()); } stack.addFirst(((IdentifierTree) node).getName()); - boolean first = true; + boolean afterFirstToken = false; for (Name name : stack) { - if (!first) { + if (afterFirstToken) { token("."); } token(name.toString()); - first = false; + afterFirstToken = true; } } @@ -2839,14 +2840,14 @@ protected void typeParametersRest( builder.open(plusIndent); builder.breakOp(); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; for (TypeParameterTree typeParameter : typeParameters) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(typeParameter, null); - first = false; + afterFirstToken = true; } token(">"); builder.close(); @@ -3238,14 +3239,14 @@ void addTypeArguments(List typeArguments, Indent plusIndent) { } token("<"); builder.open(plusIndent); - boolean first = true; + boolean afterFirstToken = false; for (Tree typeArgument : typeArguments) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakToFill(" "); } scan(typeArgument, null); - first = false; + afterFirstToken = true; } builder.close(); token(">"); @@ -3266,11 +3267,11 @@ void addArguments(List arguments, Indent plusIndent) { if (arguments.size() % 2 == 0 && argumentsAreTabular(arguments) == 2) { builder.forcedBreak(); builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; for (int i = 0; i < arguments.size() - 1; i += 2) { ExpressionTree argument0 = arguments.get(i); ExpressionTree argument1 = arguments.get(i + 1); - if (!first) { + if (afterFirstToken) { token(","); builder.forcedBreak(); } @@ -3280,7 +3281,7 @@ void addArguments(List arguments, Indent plusIndent) { builder.breakOp(" "); scan(argument1, null); builder.close(); - first = false; + afterFirstToken = true; } builder.close(); } else if (isFormatMethod(arguments)) { @@ -3304,15 +3305,15 @@ void addArguments(List arguments, Indent plusIndent) { private void argList(List arguments) { builder.open(ZERO); - boolean first = true; + boolean afterFirstToken = false; FillMode fillMode = hasOnlyShortItems(arguments) ? FillMode.INDEPENDENT : FillMode.UNIFIED; for (ExpressionTree argument : arguments) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(fillMode, " ", ZERO); } scan(argument, null); - first = false; + afterFirstToken = true; } builder.close(); } @@ -3701,12 +3702,13 @@ private void declareMany(List fragments, Direction annotationDirec int baseDims = dims.size(); maybeAddDims(dims); baseDims = baseDims - dims.size(); - boolean first = true; + boolean afterFirstToken = false; for (VariableTree fragment : fragments) { - if (!first) { + if (afterFirstToken) { token(","); } - TypeWithDims fragmentDims = variableFragmentDims(first, baseDims, fragment.getType()); + TypeWithDims fragmentDims = + variableFragmentDims(afterFirstToken, baseDims, fragment.getType()); dims = new ArrayDeque<>(fragmentDims.dims); builder.breakOp(" "); builder.open(ZERO); @@ -3723,10 +3725,10 @@ private void declareMany(List fragments, Direction annotationDirec builder.close(); } builder.close(); - if (first) { + if (!afterFirstToken) { builder.close(); } - first = false; + afterFirstToken = true; } builder.close(); token(";"); @@ -3805,14 +3807,14 @@ private void classDeclarationTypeList(String token, List types) builder.open(types.size() > 1 ? plusFour : ZERO); token(token); builder.space(); - boolean first = true; + boolean afterFirstToken = false; for (Tree type : types) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(type, null); - first = false; + afterFirstToken = true; } builder.close(); } diff --git a/core/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java index a7b5dbc44..e502f49a1 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java @@ -55,10 +55,10 @@ public Java17InputAstVisitor(OpsBuilder builder, int indentMultiplier) { } @Override - protected void handleModule(boolean first, CompilationUnitTree node) { + protected void handleModule(boolean afterFirstToken, CompilationUnitTree node) { ModuleTree module = node.getModule(); if (module != null) { - if (!first) { + if (afterFirstToken) { builder.blankLineWanted(BlankLineWanted.YES); } markForPartialFormat(); @@ -167,14 +167,14 @@ public void visitRecordDeclaration(ClassTree node) { builder.open(node.getImplementsClause().size() > 1 ? plusFour : ZERO); token("implements"); builder.space(); - boolean first = true; + boolean afterFirstToken = false; for (Tree superInterfaceType : node.getImplementsClause()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(superInterfaceType, null); - first = false; + afterFirstToken = true; } builder.close(); } @@ -238,14 +238,14 @@ public Void visitCase(CaseTree node, Void unused) { token("case", plusTwo); builder.open(labels.size() > 1 ? plusFour : ZERO); builder.space(); - boolean first = true; + boolean afterFirstToken = false; for (Tree expression : labels) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } scan(expression, null); - first = false; + afterFirstToken = true; } builder.close(); } diff --git a/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java index 5ef81fad6..8ab04e665 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java @@ -66,13 +66,13 @@ public Void visitDeconstructionPattern(DeconstructionPatternTree node, Void unus builder.open(plusFour); token("("); builder.breakOp(); - boolean first = true; + boolean afterFirstToken = false; for (PatternTree pattern : node.getNestedPatterns()) { - if (!first) { + if (afterFirstToken) { token(","); builder.breakOp(" "); } - first = false; + afterFirstToken = true; scan(pattern, null); } builder.close(); From 3366df281b9ed431b9c9681ddabc6392ac36c22b Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Tue, 30 Jan 2024 12:17:45 -0800 Subject: [PATCH 05/31] Update Truth version https://github.com/google/truth/releases/tag/v1.3.0 PiperOrigin-RevId: 602804747 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b3ca51cd..453519191 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ UTF-8 1.8 32.1.3-jre - 1.1.3 + 1.3.0 3.21.2 2.16 1.9 From c20a02715cf8be569515857d96fd558eb71cfa72 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Tue, 30 Jan 2024 12:47:17 -0800 Subject: [PATCH 06/31] Automatic code cleanup. PiperOrigin-RevId: 602812501 --- .../java/CommandLineOptionsParserTest.java | 6 ++-- .../GoogleJavaFormatToolProviderTest.java | 4 +-- .../java/GoogleJavaFormatToolTest.java | 4 +-- .../java/TypeNameClassifierTest.java | 31 ++++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java b/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java index 1a4ed09b4..2b7f3af3a 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java @@ -15,12 +15,12 @@ package com.google.googlejavaformat.java; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; +import com.google.common.truth.Truth8; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -181,11 +181,11 @@ public void paramsFile() throws IOException { @Test public void assumeFilename() { - assertThat( + Truth8.assertThat( CommandLineOptionsParser.parse(Arrays.asList("--assume-filename", "Foo.java")) .assumeFilename()) .hasValue("Foo.java"); - assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename()) + Truth8.assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename()) .isEmpty(); } diff --git a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java index 3d41a0733..3fab11770 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java @@ -15,8 +15,8 @@ package com.google.googlejavaformat.java; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; +import com.google.common.truth.Truth8; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ServiceLoader; @@ -33,7 +33,7 @@ public class GoogleJavaFormatToolProviderTest { public void testUsageOutputAfterLoadingViaToolName() { String name = "google-java-format"; - assertThat( + Truth8.assertThat( ServiceLoader.load(ToolProvider.class).stream() .map(ServiceLoader.Provider::get) .map(ToolProvider::name)) diff --git a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java index 691bb2234..e73b84cdb 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java @@ -15,9 +15,9 @@ package com.google.googlejavaformat.java; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; +import com.google.common.truth.Truth8; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -35,7 +35,7 @@ public class GoogleJavaFormatToolTest { public void testUsageOutputAfterLoadingViaToolName() { String name = "google-java-format"; - assertThat( + Truth8.assertThat( ServiceLoader.load(Tool.class).stream() .map(ServiceLoader.Provider::get) .map(Tool::name)) diff --git a/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java b/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java index 3270bc64e..be47e9f4e 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java @@ -15,9 +15,9 @@ package com.google.googlejavaformat.java; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import com.google.common.base.Splitter; +import com.google.common.truth.Truth8; import com.google.googlejavaformat.java.TypeNameClassifier.JavaCaseFormat; import java.util.Optional; import org.junit.Test; @@ -52,25 +52,26 @@ private static Optional getPrefix(String qualifiedName) { @Test public void typePrefixLength() { - assertThat(getPrefix("fieldName")).isEmpty(); - assertThat(getPrefix("CONST")).isEmpty(); - assertThat(getPrefix("ClassName")).hasValue(0); - assertThat(getPrefix("com.ClassName")).hasValue(1); - assertThat(getPrefix("ClassName.foo")).hasValue(1); - assertThat(getPrefix("com.ClassName.foo")).hasValue(2); - assertThat(getPrefix("ClassName.foo.bar")).hasValue(1); - assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2); - assertThat(getPrefix("ClassName.CONST")).hasValue(1); - assertThat(getPrefix("ClassName.varName")).hasValue(1); - assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2); - assertThat(getPrefix("com.R.foo")).hasValue(2); + Truth8.assertThat(getPrefix("fieldName")).isEmpty(); + Truth8.assertThat(getPrefix("CONST")).isEmpty(); + Truth8.assertThat(getPrefix("ClassName")).hasValue(0); + Truth8.assertThat(getPrefix("com.ClassName")).hasValue(1); + Truth8.assertThat(getPrefix("ClassName.foo")).hasValue(1); + Truth8.assertThat(getPrefix("com.ClassName.foo")).hasValue(2); + Truth8.assertThat(getPrefix("ClassName.foo.bar")).hasValue(1); + Truth8.assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2); + Truth8.assertThat(getPrefix("ClassName.CONST")).hasValue(1); + Truth8.assertThat(getPrefix("ClassName.varName")).hasValue(1); + Truth8.assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2); + Truth8.assertThat(getPrefix("com.R.foo")).hasValue(2); } @Test public void ambiguousClass() { - assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")).hasValue(7); + Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")) + .hasValue(7); // A human would probably identify this as "class-shaped", but just looking // at the case we have to assume it could be something like `field1.field2.CONST`. - assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty(); + Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty(); } } From e260fa9ca1ec69a0aa2d2ac658b5084f079ad7bf Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 5 Feb 2024 11:13:48 -0800 Subject: [PATCH 07/31] Update Truth to [1.4.0](https://github.com/google/truth/releases/tag/v1.4.0). PiperOrigin-RevId: 604375179 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 453519191..c6dc8bafd 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ UTF-8 1.8 32.1.3-jre - 1.3.0 + 1.4.0 3.21.2 2.16 1.9 From f0a6b1478ad43df32e9e5c16f847deedee4658f2 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Tue, 6 Feb 2024 12:11:12 -0800 Subject: [PATCH 08/31] Automatic code cleanup. PiperOrigin-RevId: 604725069 --- .../java/CommandLineOptionsParserTest.java | 5 ++-- .../GoogleJavaFormatToolProviderTest.java | 3 +- .../java/GoogleJavaFormatToolTest.java | 3 +- .../java/TypeNameClassifierTest.java | 30 +++++++++---------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java b/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java index 2b7f3af3a..08fbbbab3 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/CommandLineOptionsParserTest.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import com.google.common.truth.Truth8; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -181,11 +180,11 @@ public void paramsFile() throws IOException { @Test public void assumeFilename() { - Truth8.assertThat( + assertThat( CommandLineOptionsParser.parse(Arrays.asList("--assume-filename", "Foo.java")) .assumeFilename()) .hasValue("Foo.java"); - Truth8.assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename()) + assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename()) .isEmpty(); } diff --git a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java index 3fab11770..461bd6793 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProviderTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.truth.Truth8; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ServiceLoader; @@ -33,7 +32,7 @@ public class GoogleJavaFormatToolProviderTest { public void testUsageOutputAfterLoadingViaToolName() { String name = "google-java-format"; - Truth8.assertThat( + assertThat( ServiceLoader.load(ToolProvider.class).stream() .map(ServiceLoader.Provider::get) .map(ToolProvider::name)) diff --git a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java index e73b84cdb..e3a7573a7 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/GoogleJavaFormatToolTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.common.truth.Truth8; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -35,7 +34,7 @@ public class GoogleJavaFormatToolTest { public void testUsageOutputAfterLoadingViaToolName() { String name = "google-java-format"; - Truth8.assertThat( + assertThat( ServiceLoader.load(Tool.class).stream() .map(ServiceLoader.Provider::get) .map(Tool::name)) diff --git a/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java b/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java index be47e9f4e..6d7e5666c 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/TypeNameClassifierTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Splitter; -import com.google.common.truth.Truth8; import com.google.googlejavaformat.java.TypeNameClassifier.JavaCaseFormat; import java.util.Optional; import org.junit.Test; @@ -52,26 +51,25 @@ private static Optional getPrefix(String qualifiedName) { @Test public void typePrefixLength() { - Truth8.assertThat(getPrefix("fieldName")).isEmpty(); - Truth8.assertThat(getPrefix("CONST")).isEmpty(); - Truth8.assertThat(getPrefix("ClassName")).hasValue(0); - Truth8.assertThat(getPrefix("com.ClassName")).hasValue(1); - Truth8.assertThat(getPrefix("ClassName.foo")).hasValue(1); - Truth8.assertThat(getPrefix("com.ClassName.foo")).hasValue(2); - Truth8.assertThat(getPrefix("ClassName.foo.bar")).hasValue(1); - Truth8.assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2); - Truth8.assertThat(getPrefix("ClassName.CONST")).hasValue(1); - Truth8.assertThat(getPrefix("ClassName.varName")).hasValue(1); - Truth8.assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2); - Truth8.assertThat(getPrefix("com.R.foo")).hasValue(2); + assertThat(getPrefix("fieldName")).isEmpty(); + assertThat(getPrefix("CONST")).isEmpty(); + assertThat(getPrefix("ClassName")).hasValue(0); + assertThat(getPrefix("com.ClassName")).hasValue(1); + assertThat(getPrefix("ClassName.foo")).hasValue(1); + assertThat(getPrefix("com.ClassName.foo")).hasValue(2); + assertThat(getPrefix("ClassName.foo.bar")).hasValue(1); + assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2); + assertThat(getPrefix("ClassName.CONST")).hasValue(1); + assertThat(getPrefix("ClassName.varName")).hasValue(1); + assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2); + assertThat(getPrefix("com.R.foo")).hasValue(2); } @Test public void ambiguousClass() { - Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")) - .hasValue(7); + assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")).hasValue(7); // A human would probably identify this as "class-shaped", but just looking // at the case we have to assume it could be something like `field1.field2.CONST`. - Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty(); + assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty(); } } From ca02b8dbbf80412321f56b63a982319b95ad92c1 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 9 Feb 2024 21:38:12 +0100 Subject: [PATCH 09/31] Remove un-used GitHub Action Parameter The https://github.com/oracle-actions/setup-java/tree/v1/?tab=readme-ov-file#input-overview does not have a "cache" parameter (like https://github.com/actions/setup-java/tree/v4/?tab=readme-ov-file#usage does). --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51ecf6e80..6a2f986b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,6 @@ jobs: with: website: jdk.java.net release: ${{ matrix.java }} - cache: 'maven' - name: 'Set up JDK ${{ matrix.java }}' if: ${{ matrix.java != 'EA' }} uses: actions/setup-java@v4 From 297dda474899fa380acd579ba48ff8f269bc9a48 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 9 Feb 2024 17:00:53 -0800 Subject: [PATCH 10/31] docs: Add link to a VSC Extension to README (fixes #488) There are a bunch of these; I've had a a bit of a closer look at them the other day, and this one appears to be the most up-to-date, actively maintained, and contrary to the the other more popular by stars older ones seems easy to use because it doesn't require anything to be externally pre-installed but just download from this project's GitHub releases; that's why I'm proposing adding this one. This fixes #488. @cushon LGTY? Fixes #1043 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1043 from vorburger:patch-3 e48524b986133d05e9331bdfc9be75349a6f39df PiperOrigin-RevId: 605769445 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fe0e2126..38fdac5e8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Using the formatter -### from the command-line +### From the command-line [Download the formatter](https://github.com/google/google-java-format/releases) and run it with: @@ -78,6 +78,8 @@ Implementation`. ### Third-party integrations +* Visual Studio Code + * [google-java-format-for-vs-code](https://marketplace.visualstudio.com/items?itemName=JoseVSeb.google-java-format-for-vs-code) * Gradle plugins * [spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format) * [sherter/google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradle-plugin) From 84582bf73fef63b7ffe7fa8d7bb8e7cdab3c73eb Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 10 Feb 2024 11:43:50 +0000 Subject: [PATCH 11/31] Mechanically reformat GitHub Actions YAML https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions proposes this format as the "canonical" one. Adopting this makes it easier to contribute to this project by using that VSC Extension as an editor. This change is purely mechanical and contains no other "semantic" differences. --- .github/workflows/ci.yml | 36 +++++++++++++++++------------------ .github/workflows/release.yml | 10 ++++------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a2f986b4..f5457cb9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ name: CI on: push: branches: - - master + - master pull_request: branches: - - master + - master jobs: test: @@ -28,9 +28,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] - java: [ 21, 17, 11 ] - experimental: [ false ] + os: [ubuntu-latest] + java: [21, 17, 11] + experimental: [false] include: # Only test on macos and windows with a single recent JDK to avoid a # combinatorial explosion of test configurations. @@ -50,46 +50,46 @@ jobs: uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} - - name: 'Check out repository' + - name: "Check out repository" uses: actions/checkout@v4 - - name: 'Set up JDK ${{ matrix.java }} from jdk.java.net' + - name: "Set up JDK ${{ matrix.java }} from jdk.java.net" if: ${{ matrix.java == 'EA' }} uses: oracle-actions/setup-java@v1 with: website: jdk.java.net release: ${{ matrix.java }} - - name: 'Set up JDK ${{ matrix.java }}' + - name: "Set up JDK ${{ matrix.java }}" if: ${{ matrix.java != 'EA' }} uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} - distribution: 'zulu' - cache: 'maven' - - name: 'Install' + distribution: "zulu" + cache: "maven" + - name: "Install" shell: bash run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - - name: 'Test' + - name: "Test" shell: bash run: mvn test -B publish_snapshot: - name: 'Publish snapshot' + name: "Publish snapshot" needs: test if: github.event_name == 'push' && github.repository == 'google/google-java-format' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - - name: 'Check out repository' + - name: "Check out repository" uses: actions/checkout@v4 - - name: 'Set up JDK 17' + - name: "Set up JDK 17" uses: actions/setup-java@v4 with: java-version: 17 - distribution: 'zulu' - cache: 'maven' + distribution: "zulu" + cache: "maven" server-id: sonatype-nexus-snapshots server-username: CI_DEPLOY_USERNAME server-password: CI_DEPLOY_PASSWORD - - name: 'Publish' + - name: "Publish" env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf50d61c6..717e6fd6a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,8 @@ jobs: uses: actions/setup-java@v4 with: java-version: 21 - distribution: 'zulu' - cache: 'maven' + distribution: "zulu" + cache: "maven" server-id: sonatype-nexus-staging server-username: CI_DEPLOY_USERNAME server-password: CI_DEPLOY_PASSWORD @@ -46,12 +46,10 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - run: - mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release clean deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" + run: mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release clean deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" - name: Build Eclipse plugin - run: - mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" + run: mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" - name: Push tag run: | From 9e11f30c389d3a9bd8139792466d523375c4842c Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 10 Feb 2024 11:46:54 +0000 Subject: [PATCH 12/31] Add missing ASL (license) to GitHub Actions --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5457cb9d..9da84de0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# Copyright 2020 The Error Prone Authors. +# Copyright 2020 The Google Java Format Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 717e6fd6a..a0bf2c6c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,17 @@ +# Copyright 2020 The Google Java Format Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Release google-java-format on: From 77cb16857ca88d2a16295b8c81ae4b1cbb3aeca0 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 11 Feb 2024 11:13:33 -0800 Subject: [PATCH 13/31] Bump native-maven-plugin from 0.9.13 to 0.10.0 (latest) @cushon perhaps merge this separately already? Fixes #1051 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1051 from vorburger:patch-5 7520ec5f784c47a39726ca2ef1eb81c89c7cdfc4 PiperOrigin-RevId: 606060781 --- core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index d1363fed1..60add52d1 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -282,7 +282,7 @@ org.graalvm.buildtools native-maven-plugin - 0.9.13 + 0.10.0 true From 3d9c8fa1cd6eff1f3bd94c6e367501a622088d59 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 10 Feb 2024 11:39:29 +0000 Subject: [PATCH 14/31] Build native binary in CI (fixes google#894) --- .github/workflows/ci.yml | 23 +++++++++++++++++++---- .github/workflows/release.yml | 4 ++-- util/test-native.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100755 util/test-native.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9da84de0b..e03234959 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - java: [21, 17, 11] + java: [GraalVM, 21, 17, 11] experimental: [false] include: - # Only test on macos and windows with a single recent JDK to avoid a + # Only test on MacOS and Windows with a single recent JDK to avoid a # combinatorial explosion of test configurations. - os: macos-latest java: 21 @@ -43,6 +43,9 @@ jobs: - os: ubuntu-latest java: EA experimental: true + - os: ubuntu-latest + java: GraalVM + experimental: false runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} steps: @@ -58,19 +61,31 @@ jobs: with: website: jdk.java.net release: ${{ matrix.java }} - - name: "Set up JDK ${{ matrix.java }}" - if: ${{ matrix.java != 'EA' }} + - name: "Set up JDK ${{ matrix.java }} from Zulu" + if: ${{ matrix.java != 'EA' && matrix.java != 'GraalVM' }} uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: "zulu" cache: "maven" + - name: "Set up JDK ${{ matrix.java }}" + if: ${{ matrix.java == 'GraalVM' }} + uses: graalvm/setup-graalvm@v1 + with: + java-version: "21" + distribution: "graalvm-community" + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: "true" + cache: "maven" - name: "Install" shell: bash run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - name: "Test" shell: bash run: mvn test -B + - name: "Native" + if: ${{ matrix.java == 'GraalVM' }} + run: mvn -Pnative -DskipTests package -pl core -am && util/test-native.sh publish_snapshot: name: "Publish snapshot" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0bf2c6c8..cf57f3e94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: run: | git push origin "v${{ github.event.inputs.version }}" - - name: Add Jars to Release Entry + - name: Add Artifacts to Release Entry uses: softprops/action-gh-release@v0.1.14 with: draft: true @@ -77,5 +77,5 @@ jobs: tag_name: "v${{ github.event.inputs.version }}" target_commitish: ${{ env.TARGET_COMMITISH }} files: | - core/target/google-java-format-*.jar + core/target/google-java-format* eclipse_plugin/target/google-java-format-eclipse-plugin-*.jar diff --git a/util/test-native.sh b/util/test-native.sh new file mode 100755 index 000000000..a8643baf2 --- /dev/null +++ b/util/test-native.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Copyright 2024 The Google Java Format Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euox pipefail + +time java -jar core/target/google-java-format-*-all-deps.jar || true + +status=-1 +chmod +x core/target/google-java-format +if time core/target/google-java-format; then + status=0 +else + status=$? +fi +if [[ $status -ne 2 ]]; then + echo "google-java-format_linux (native) without arguments should have printed usage help and exited with 2, but did not :(" + exit 1 +fi From ea57ad1e2a291ca1582aa76925b089077a610db5 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 11 Feb 2024 20:53:16 +0000 Subject: [PATCH 15/31] Refactor CI to run GraalVM native build in separate job --- .github/workflows/ci.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e03234959..0c8cc2b58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,13 +23,13 @@ on: - master jobs: - test: + test-OpenJDK: name: "JDK ${{ matrix.java }} on ${{ matrix.os }}" strategy: fail-fast: false matrix: os: [ubuntu-latest] - java: [GraalVM, 21, 17, 11] + java: [21, 17, 11] experimental: [false] include: # Only test on MacOS and Windows with a single recent JDK to avoid a @@ -43,9 +43,6 @@ jobs: - os: ubuntu-latest java: EA experimental: true - - os: ubuntu-latest - java: GraalVM - experimental: false runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} steps: @@ -83,6 +80,31 @@ jobs: - name: "Test" shell: bash run: mvn test -B + + test-OpenJDK: + name: "GraalVM on ${{ matrix.os }}" + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + steps: + - name: Cancel previous + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - name: "Check out repository" + uses: actions/checkout@v4 + - name: "Set up GraalVM ${{ matrix.java }}" + if: ${{ matrix.java == 'GraalVM' }} + uses: graalvm/setup-graalvm@v1 + with: + java-version: "21" + distribution: "graalvm-community" + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: "true" + cache: "maven" - name: "Native" if: ${{ matrix.java == 'GraalVM' }} run: mvn -Pnative -DskipTests package -pl core -am && util/test-native.sh From 6cf0e35c956461204c8dbc90895ea4d53800010a Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Sun, 11 Feb 2024 14:51:05 -0800 Subject: [PATCH 16/31] Update ci.yml Fix some typos--update references from `test` to `test-OpenJDK`, remove a stale reference to `matrix.experimental` from GraalVM tests --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c8cc2b58..322f914e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,14 +81,14 @@ jobs: shell: bash run: mvn test -B - test-OpenJDK: + test-GraalVM: name: "GraalVM on ${{ matrix.os }}" strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} + continue-on-error: true steps: - name: Cancel previous uses: styfle/cancel-workflow-action@0.9.1 @@ -111,7 +111,7 @@ jobs: publish_snapshot: name: "Publish snapshot" - needs: test + needs: test-OpenJDK if: github.event_name == 'push' && github.repository == 'google/google-java-format' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: From 1ae69f9424e9c77611c893c9917993a4d31f6833 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Sun, 11 Feb 2024 14:54:36 -0800 Subject: [PATCH 17/31] Remove obsolete test for matrix.java == 'GraalVM' --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 322f914e0..ff402eff4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,6 @@ jobs: - name: "Check out repository" uses: actions/checkout@v4 - name: "Set up GraalVM ${{ matrix.java }}" - if: ${{ matrix.java == 'GraalVM' }} uses: graalvm/setup-graalvm@v1 with: java-version: "21" @@ -106,7 +105,6 @@ jobs: native-image-job-reports: "true" cache: "maven" - name: "Native" - if: ${{ matrix.java == 'GraalVM' }} run: mvn -Pnative -DskipTests package -pl core -am && util/test-native.sh publish_snapshot: From ad089da9736bc849454e793226cdc8f1f9fa6d12 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 12 Feb 2024 16:02:26 -0800 Subject: [PATCH 18/31] Handle 'any' patterns Fixes https://github.com/google/google-java-format/issues/1037 PiperOrigin-RevId: 606394473 --- .../java/java21/Java21InputAstVisitor.java | 18 +++++++++++ .../java/FormatterIntegrationTest.java | 3 +- .../java/testdata/I1037.input | 11 +++++++ .../java/testdata/I1037.output | 11 +++++++ util/test-native.sh | 30 ------------------- 5 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.input create mode 100644 core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.output delete mode 100755 util/test-native.sh diff --git a/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java index 8ab04e665..2192a32a9 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/java21/Java21InputAstVisitor.java @@ -24,6 +24,8 @@ import com.sun.source.tree.PatternCaseLabelTree; import com.sun.source.tree.PatternTree; import com.sun.source.tree.StringTemplateTree; +import com.sun.source.tree.Tree; +import com.sun.tools.javac.tree.JCTree; import javax.lang.model.element.Name; /** @@ -107,4 +109,20 @@ protected void variableName(Name name) { visit(name); } } + + @Override + public Void scan(Tree tree, Void unused) { + // Pre-visit AST for preview features, since com.sun.source.tree.AnyPattern can't be + // accessed directly without --enable-preview. + if (tree instanceof JCTree.JCAnyPattern) { + visitJcAnyPattern((JCTree.JCAnyPattern) tree); + return null; + } else { + return super.scan(tree, unused); + } + } + + private void visitJcAnyPattern(JCTree.JCAnyPattern unused) { + token("_"); + } } diff --git a/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java b/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java index 26493b022..15a6e75f9 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java @@ -62,7 +62,8 @@ public class FormatterIntegrationTest { "Unnamed", "I981", "StringTemplate", - "I1020") + "I1020", + "I1037") .build(); @Parameters(name = "{index}: {0}") diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.input b/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.input new file mode 100644 index 000000000..ed39459dd --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.input @@ -0,0 +1,11 @@ +public sealed interface A { + record AA(Long a) implements A {} + + static Long mySwitch(A a) { + switch (a) { + case AA(_) -> { + return 1L; + } + } + } +} diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.output b/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.output new file mode 100644 index 000000000..ed39459dd --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/I1037.output @@ -0,0 +1,11 @@ +public sealed interface A { + record AA(Long a) implements A {} + + static Long mySwitch(A a) { + switch (a) { + case AA(_) -> { + return 1L; + } + } + } +} diff --git a/util/test-native.sh b/util/test-native.sh deleted file mode 100755 index a8643baf2..000000000 --- a/util/test-native.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2024 The Google Java Format Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -euox pipefail - -time java -jar core/target/google-java-format-*-all-deps.jar || true - -status=-1 -chmod +x core/target/google-java-format -if time core/target/google-java-format; then - status=0 -else - status=$? -fi -if [[ $status -ne 2 ]]; then - echo "google-java-format_linux (native) without arguments should have printed usage help and exited with 2, but did not :(" - exit 1 -fi From c5c3deb61f7e6a848bdf4943dcc59fc1d505b16d Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 13 Feb 2024 09:29:52 -0800 Subject: [PATCH 19/31] Add `util/test-native.sh` from https://github.com/google/google-java-format/pull/1048 PiperOrigin-RevId: 606648629 --- util/test-native.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 util/test-native.sh diff --git a/util/test-native.sh b/util/test-native.sh new file mode 100644 index 000000000..a8643baf2 --- /dev/null +++ b/util/test-native.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Copyright 2024 The Google Java Format Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euox pipefail + +time java -jar core/target/google-java-format-*-all-deps.jar || true + +status=-1 +chmod +x core/target/google-java-format +if time core/target/google-java-format; then + status=0 +else + status=$? +fi +if [[ $status -ne 2 ]]; then + echo "google-java-format_linux (native) without arguments should have printed usage help and exited with 2, but did not :(" + exit 1 +fi From 6b4828af0fc0b82c1132f1119fc722208cab53d2 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 13 Feb 2024 12:12:14 -0800 Subject: [PATCH 20/31] Fix chmod +x util/test-native.sh which Copybara broke @cushon Fixes #1059 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1059 from vorburger:chmod-test-native 27966592f76074dcb377517bdeea5d648097b358 PiperOrigin-RevId: 606705116 --- util/test-native.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 util/test-native.sh diff --git a/util/test-native.sh b/util/test-native.sh old mode 100644 new mode 100755 From 59b09facf3f606b25290ba5070de8a4f81d46ea8 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 13 Feb 2024 12:14:46 -0800 Subject: [PATCH 21/31] Bump Maven JavaDoc plugin from 3.4.0 to 3.6.3 to fix build failure [This build](https://github.com/google/google-java-format/actions/runs/7891365432/job/21535541300?pr=1060) for #1060 failed on (only) Windows under GraalVM for Native and I suspect that this change may fix this problem: ``` Error: Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.4.0:jar (attach-javadocs) on project google-java-format: MavenReportException: Error while generating Javadoc: Error: Exit code: 1 - Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\CloseOp.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\CommentsHelper.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Doc.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\DocBuilder.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\FormatterDiagnostic.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\FormattingError.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Indent.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Input.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\InputOutput.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\CommandLineOptions.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\CommandLineOptionsParser.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\DimensionHelpers.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\filer\FormattingFiler.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\filer\FormattingJavaFileObject.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\FormatFileCallable.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\Formatter.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\FormatterException.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\GoogleJavaFormatTool.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\GoogleJavaFormatToolProvider.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\ImportOrderer.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\java17\Java17InputAstVisitor.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\java21\Java21InputAstVisitor.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavaCommentsHelper.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavacTokens.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\CharStream.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\JavadocFormatter.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\JavadocLexer.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\JavadocWriter.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\NestingCounter.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\javadoc\Token.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavaFormatterOptions.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavaInput.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavaInputAstVisitor.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\JavaOutput.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\Main.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\ModifierOrderer.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\RemoveUnusedImports.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\Replacement.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\SnippetFormatter.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\StringWrapper.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\Trees.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\TypeNameClassifier.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\UsageException.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Newlines.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Op.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\OpenOp.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\OpsBuilder.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\Output.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\target\generated-sources\java\com\google\googlejavaformat\java\GoogleJavaFormatVersion.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\target\generated-sources\annotations\com\google\googlejavaformat\java\AutoOneOf_JavaInputAstVisitor_AnnotationOrModifier.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\target\generated-sources\annotations\com\google\googlejavaformat\java\AutoValue_FormatFileCallable_Result.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\target\generated-sources\annotations\com\google\googlejavaformat\java\AutoValue_JavaFormatterOptions.java... Error: Loading source file D:\a\google-java-format\google-java-format\core\target\generated-sources\annotations\com\google\googlejavaformat\java\AutoValue_JavaInputAstVisitor_DeclarationModifiersAndTypeAnnotations.java... Error: Loading source files for package com.google.googlejavaformat... Error: Loading source files for package com.google.googlejavaformat.java... Error: Loading source files for package com.google.googlejavaformat.java.filer... Error: Loading source files for package com.google.googlejavaformat.java.java17... Error: Loading source files for package com.google.googlejavaformat.java.java21... Error: Loading source files for package com.google.googlejavaformat.java.javadoc... Error: Constructing Javadoc information... Error: D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\DimensionHelpers.java:18: error: package com.sun.source.tree is not visible Error: import com.sun.source.tree.AnnotatedTypeTree; Error: ^ Error: (package com.sun.source.tree is declared in module jdk.compiler, but module com.google.googlejavaformat does not read it) Error: D:\a\google-java-format\google-java-format\core\src\main\java\com\google\googlejavaformat\java\DimensionHelpers.java:19: error: package com.sun.source.tree is not visible Error: import com.sun.source.tree.AnnotationTree; (...) ``` @cushon @cpovirk merge? Fixes #1061 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1061 from vorburger:maven-javadoc-plugin c3c4b6fcc2f7a448aa0329754dcc0b685566b153 PiperOrigin-RevId: 606705880 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c6dc8bafd..2b426cee1 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ 2.16 1.9 1.0.1 - 3.4.0 + 3.6.3 3.2.1 @@ -172,7 +172,7 @@ maven-javadoc-plugin - 3.4.0 + ${maven-javadoc-plugin.version} maven-gpg-plugin @@ -260,7 +260,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.0 + ${maven-javadoc-plugin.version} none From b9b41faf47e13692c02a517ea9ebe7d173fe7374 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 13 Feb 2024 18:51:59 +0000 Subject: [PATCH 22/31] Add Windows native build --- .github/workflows/ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff402eff4..ab0ebf024 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} continue-on-error: true steps: @@ -104,8 +104,13 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: "true" cache: "maven" - - name: "Native" - run: mvn -Pnative -DskipTests package -pl core -am && util/test-native.sh + - name: "Native Build" + run: mvn -Pnative -DskipTests package -pl core -am + - name: "Native Test" + # Bash script for testing won't work on Windows + # TODO: Anyone reading this wants to write a *.bat or *.ps1 equivalent? + if: ${{ matrix.os != 'windows-latest' }} + run: util/test-native.sh publish_snapshot: name: "Publish snapshot" From 9851a393fede8821489317d54e5bf02e6dc0bf72 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 12 Feb 2024 16:09:19 -0800 Subject: [PATCH 23/31] Generate native-image binaries for google-java-format And include them in release artifacts. I tested this on my fork of the repo, and have a demo here: https://github.com/cushon/google-java-format/releases When downloading the artifacts from the releases page they don't have the executable bit set, and my Mac blocks them because they aren't signed. That can be worked around with the following, but isn't ideal: ``` chmod a+rx google-java-format-darwin sudo xattr -r -d com.apple.quarantine google-java-format-darwin ``` Progress towards #868 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf57f3e94..3dafd8cd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,3 +79,31 @@ jobs: files: | core/target/google-java-format* eclipse_plugin/target/google-java-format-eclipse-plugin-*.jar + + build-native-image: + name: "Build GraalVM native-image on ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + needs: build-maven-jars + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: "Check out repository" + uses: actions/checkout@v4 + - name: "Set up GraalVM" + uses: graalvm/setup-graalvm@v1 + with: + java-version: "21" + distribution: "graalvm-community" + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: "true" + cache: "maven" + - name: "Native" + run: mvn -Pnative -DskipTests package -pl core -am + - name: "Move outputs" + run: cp core/target/google-java-format google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} + - name: "Upload native-image" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }}" From 4e9aa25d91968d6b7bd01482e06eaf12b2ff20cd Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 15 Feb 2024 12:39:24 -0800 Subject: [PATCH 24/31] Update .github/workflows/release.yml Co-authored-by: Michael Vorburger --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3dafd8cd3..0848c869d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,7 +86,7 @@ jobs: needs: build-maven-jars strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: "Check out repository" uses: actions/checkout@v4 From 0bc08ab915eaee7cb6063fe2963df4108e5b84f4 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 15 Feb 2024 12:55:20 -0800 Subject: [PATCH 25/31] Update release.yml --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0848c869d..e1f94aaa0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,6 +87,8 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] + env: + SUFFIX: ${{fromJson('{"ubuntu-latest":"linux-x86_64", "macos-latest":"darwin-arm64", "windows-latest":"windows_x86-64"}')[matrix.os]}} steps: - name: "Check out repository" uses: actions/checkout@v4 @@ -101,9 +103,9 @@ jobs: - name: "Native" run: mvn -Pnative -DskipTests package -pl core -am - name: "Move outputs" - run: cp core/target/google-java-format google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} + run: cp core/target/google-java-format google-java-format-${{ env.SUFFIX }} - name: "Upload native-image" env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} - run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }}" + run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format-${{ env.SUFFIX }}" From 865cdf873e13be398f6346bb54b7be5fd58c1498 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 16 Feb 2024 08:25:46 -0800 Subject: [PATCH 26/31] Apply suggestions from code review Co-authored-by: Michael Vorburger --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1f94aaa0..36c0eb59d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,7 +88,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] env: - SUFFIX: ${{fromJson('{"ubuntu-latest":"linux-x86_64", "macos-latest":"darwin-arm64", "windows-latest":"windows_x86-64"}')[matrix.os]}} + SUFFIX: ${{fromJson('{"ubuntu-latest":"linux-x86-64", "macos-latest":"darwin-arm64", "windows-latest":"windows-x86-64"}')[matrix.os]}} steps: - name: "Check out repository" uses: actions/checkout@v4 @@ -103,9 +103,9 @@ jobs: - name: "Native" run: mvn -Pnative -DskipTests package -pl core -am - name: "Move outputs" - run: cp core/target/google-java-format google-java-format-${{ env.SUFFIX }} + run: cp core/target/google-java-format google-java-format_${{ env.SUFFIX }} - name: "Upload native-image" env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} - run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format-${{ env.SUFFIX }}" + run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format_${{ env.SUFFIX }}" From 250fa9be7ae921b80c64d3bfe046faff8f3d0009 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 16 Feb 2024 14:37:19 -0800 Subject: [PATCH 27/31] Update release.yml Only update `.jar` files from main build This un-does a change made in anticipation of uploading native image artifacts, but they are uploaded by separate steps, and we want to exclude other outputs the maven build generates. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36c0eb59d..904a8c3be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,7 @@ jobs: tag_name: "v${{ github.event.inputs.version }}" target_commitish: ${{ env.TARGET_COMMITISH }} files: | - core/target/google-java-format* + core/target/google-java-format-*.jar eclipse_plugin/target/google-java-format-eclipse-plugin-*.jar build-native-image: From 910586c6390861c448ab7b69fe0fe88a803012dd Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 16 Feb 2024 14:56:00 -0800 Subject: [PATCH 28/31] Handle `.exe` extensions for windows native-image --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 904a8c3be..2f309026b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,6 +89,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] env: SUFFIX: ${{fromJson('{"ubuntu-latest":"linux-x86-64", "macos-latest":"darwin-arm64", "windows-latest":"windows-x86-64"}')[matrix.os]}} + EXTENSION: ${{ matrix.os == 'windows-latest' && '.exe' || '' }} steps: - name: "Check out repository" uses: actions/checkout@v4 @@ -103,9 +104,9 @@ jobs: - name: "Native" run: mvn -Pnative -DskipTests package -pl core -am - name: "Move outputs" - run: cp core/target/google-java-format google-java-format_${{ env.SUFFIX }} + run: cp core/target/google-java-format${{ env.EXTENSION }} google-java-format_${{ env.SUFFIX }}${{ env.EXTENSION }} - name: "Upload native-image" env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} - run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format_${{ env.SUFFIX }}" + run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format_${{ env.SUFFIX }}${{ env.EXTENSION }}" From 571c2b6ea232e295158154c9fbd6ef18f9e97942 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 16 Feb 2024 16:38:04 -0800 Subject: [PATCH 29/31] Update maven native-image configuration for google-java-format PiperOrigin-RevId: 607835047 --- core/pom.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index 60add52d1..064f9dee8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -288,7 +288,7 @@ build-native - build + compile-no-fork package @@ -306,9 +306,19 @@ ${project.build.directory}/${project.artifactId}-${project.version}-all-deps.jar + -H:+UnlockExperimentalVMOptions -H:IncludeResourceBundles=com.sun.tools.javac.resources.compiler + -H:IncludeResourceBundles=com.sun.tools.javac.resources.javac --no-fallback --initialize-at-build-time=com.sun.tools.javac.file.Locations + -H:+ReportExceptionStackTraces + -H:-UseContainerSupport + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED From 92c609a43bc894e4cd69e9c037491163303d97ed Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 16 Feb 2024 17:42:59 -0800 Subject: [PATCH 30/31] Set `-march=compatibility` for native-image builds This avoids CPU features that may not be available on all machines. Currently I'm seeing errors trying to run binaries built on the Github Actions machines locally on a M1. PiperOrigin-RevId: 607847525 --- core/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/pom.xml b/core/pom.xml index 064f9dee8..7b4a1d1f2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -319,6 +319,7 @@ -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -march=compatibility From 38a7b73c9865270aaaa9273d5674b8ce2dd8f954 Mon Sep 17 00:00:00 2001 From: cushon Date: Sat, 17 Feb 2024 03:02:34 +0000 Subject: [PATCH 31/31] Release google-java-format 1.20.0 --- core/pom.xml | 2 +- eclipse_plugin/META-INF/MANIFEST.MF | 2 +- eclipse_plugin/pom.xml | 2 +- pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 7b4a1d1f2..d0d803a81 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -22,7 +22,7 @@ com.google.googlejavaformat google-java-format-parent - HEAD-SNAPSHOT + 1.20.0 google-java-format diff --git a/eclipse_plugin/META-INF/MANIFEST.MF b/eclipse_plugin/META-INF/MANIFEST.MF index 913245393..531fb8410 100644 --- a/eclipse_plugin/META-INF/MANIFEST.MF +++ b/eclipse_plugin/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: google-java-format Bundle-SymbolicName: google-java-format-eclipse-plugin;singleton:=true Bundle-Vendor: Google -Bundle-Version: 1.13.0 +Bundle-Version: 1.20.0 Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.eclipse.jdt.core;bundle-version="3.10.0", org.eclipse.jface, diff --git a/eclipse_plugin/pom.xml b/eclipse_plugin/pom.xml index 9e6acdac0..25b2bac8a 100644 --- a/eclipse_plugin/pom.xml +++ b/eclipse_plugin/pom.xml @@ -22,7 +22,7 @@ com.google.googlejavaformat google-java-format-eclipse-plugin eclipse-plugin - 1.13.0 + 1.20.0 Google Java Format Plugin for Eclipse 4.5+ diff --git a/pom.xml b/pom.xml index 2b426cee1..04abf5c3b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ com.google.googlejavaformat google-java-format-parent pom - HEAD-SNAPSHOT + 1.20.0 core