diff --git a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11JavadocVisitor.java b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11JavadocVisitor.java index cd35b3e43f3..75e1e9f1202 100644 --- a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11JavadocVisitor.java +++ b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11JavadocVisitor.java @@ -33,7 +33,6 @@ import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.LeadingBrace; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1155,20 +1154,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) { int saveCursor = cursor; Space before = whitespace(); JLeftPadded dimension; - Markers markers = Markers.EMPTY; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - dimension = JLeftPadded.build(EMPTY).withBefore(EMPTY); - markers = markers.addIfAbsent(new OmitBrackets(Tree.randomId())); - } else { + if (source.startsWith("[", cursor)) { cursor++; dimension = JLeftPadded.build(Space.build(sourceBeforeAsString("]"), emptyList())).withBefore(before); + } else { + cursor = saveCursor; + return elemType; } return new J.ArrayType( randomId(), fmt, - markers, + Markers.EMPTY, elemType, null, dimension, diff --git a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11ParserVisitor.java b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11ParserVisitor.java index 3ea8ebe444e..304ffbc46c5 100644 --- a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11ParserVisitor.java +++ b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11ParserVisitor.java @@ -34,7 +34,6 @@ import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.JavaParsingException; import org.openrewrite.java.internal.JavaTypeCache; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.marker.OmitParentheses; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1282,22 +1281,11 @@ private TypeTree arrayTypeTree(Tree tree, Map annotationP } Space prefix = whitespace(); - Markers markers = Markers.EMPTY; TypeTree elemType = convert(typeIdent); List annotations = leadingAnnotations(annotationPosTable); - JLeftPadded dimension; - int saveCursor = cursor; - whitespace(); - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { - cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); - } + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); assert arrayTypeTree != null; - return new J.ArrayType(randomId(), prefix, markers, + return new J.ArrayType(randomId(), prefix, Markers.EMPTY, count == 1 ? elemType : mapDimensions(elemType, arrayTypeTree.getType(), annotationPosTable), annotations, dimension, @@ -1315,26 +1303,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map annotations = leadingAnnotations(annotationPosTable); int saveCursor = cursor; whitespace(); - Markers markers = Markers.EMPTY; - JLeftPadded dimension; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { + if (source.startsWith("[", cursor)) { cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); + return new J.ArrayType( + randomId(), + EMPTY, + Markers.EMPTY, + mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), + annotations, + dimension, + typeMapping.type(tree) + ); } - - return new J.ArrayType( - randomId(), - EMPTY, - markers, - mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), - annotations, - dimension, - typeMapping.type(tree) - ); + cursor = saveCursor; } return baseType; } diff --git a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17JavadocVisitor.java b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17JavadocVisitor.java index 9080cd8d3ed..b4ec5d3c105 100644 --- a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17JavadocVisitor.java +++ b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17JavadocVisitor.java @@ -36,7 +36,6 @@ import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.LeadingBrace; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1160,20 +1159,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) { int saveCursor = cursor; Space before = whitespace(); JLeftPadded dimension; - Markers markers = Markers.EMPTY; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - dimension = JLeftPadded.build(EMPTY).withBefore(EMPTY); - markers = markers.addIfAbsent(new OmitBrackets(Tree.randomId())); - } else { + if (source.startsWith("[", cursor)) { cursor++; dimension = JLeftPadded.build(Space.build(sourceBeforeAsString("]"), emptyList())).withBefore(before); + } else { + cursor = saveCursor; + return elemType; } return new J.ArrayType( randomId(), fmt, - markers, + Markers.EMPTY, elemType, null, dimension, diff --git a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java index afb56502329..50c0829c2ef 100644 --- a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java +++ b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java @@ -35,7 +35,6 @@ import org.openrewrite.java.JavaParsingException; import org.openrewrite.java.internal.JavaTypeCache; import org.openrewrite.java.marker.CompactConstructor; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.marker.OmitParentheses; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1359,22 +1358,11 @@ private TypeTree arrayTypeTree(Tree tree, Map annotationP } Space prefix = whitespace(); - Markers markers = Markers.EMPTY; TypeTree elemType = convert(typeIdent); List annotations = leadingAnnotations(annotationPosTable); - JLeftPadded dimension; - int saveCursor = cursor; - whitespace(); - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { - cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); - } + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); assert arrayTypeTree != null; - return new J.ArrayType(randomId(), prefix, markers, + return new J.ArrayType(randomId(), prefix, Markers.EMPTY, count == 1 ? elemType : mapDimensions(elemType, arrayTypeTree.getType(), annotationPosTable), annotations, dimension, @@ -1392,26 +1380,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map annotations = leadingAnnotations(annotationPosTable); int saveCursor = cursor; whitespace(); - Markers markers = Markers.EMPTY; - JLeftPadded dimension; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { + if (source.startsWith("[", cursor)) { cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); + return new J.ArrayType( + randomId(), + EMPTY, + Markers.EMPTY, + mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), + annotations, + dimension, + typeMapping.type(tree) + ); } - - return new J.ArrayType( - randomId(), - EMPTY, - markers, - mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), - annotations, - dimension, - typeMapping.type(tree) - ); + cursor = saveCursor; } return baseType; } diff --git a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21JavadocVisitor.java b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21JavadocVisitor.java index 8d372b52471..b6ed208cd32 100644 --- a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21JavadocVisitor.java +++ b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21JavadocVisitor.java @@ -36,7 +36,6 @@ import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.LeadingBrace; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1159,20 +1158,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) { int saveCursor = cursor; Space before = whitespace(); JLeftPadded dimension; - Markers markers = Markers.EMPTY; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - dimension = JLeftPadded.build(EMPTY).withBefore(EMPTY); - markers = markers.addIfAbsent(new OmitBrackets(Tree.randomId())); - } else { + if (source.startsWith("[", cursor)) { cursor++; dimension = JLeftPadded.build(Space.build(sourceBeforeAsString("]"), emptyList())).withBefore(before); + } else { + cursor = saveCursor; + return elemType; } return new J.ArrayType( randomId(), fmt, - markers, + Markers.EMPTY, elemType, null, dimension, diff --git a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21ParserVisitor.java b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21ParserVisitor.java index 792e6874a33..10b90522da6 100644 --- a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21ParserVisitor.java +++ b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21ParserVisitor.java @@ -35,7 +35,6 @@ import org.openrewrite.java.JavaParsingException; import org.openrewrite.java.internal.JavaTypeCache; import org.openrewrite.java.marker.CompactConstructor; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.marker.OmitParentheses; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1357,22 +1356,11 @@ private TypeTree arrayTypeTree(Tree tree, Map annotationP } Space prefix = whitespace(); - Markers markers = Markers.EMPTY; TypeTree elemType = convert(typeIdent); List annotations = leadingAnnotations(annotationPosTable); - JLeftPadded dimension; - int saveCursor = cursor; - whitespace(); - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { - cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); - } + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); assert arrayTypeTree != null; - return new J.ArrayType(randomId(), prefix, markers, + return new J.ArrayType(randomId(), prefix, Markers.EMPTY, count == 1 ? elemType : mapDimensions(elemType, arrayTypeTree.getType(), annotationPosTable), annotations, dimension, @@ -1390,26 +1378,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map annotations = leadingAnnotations(annotationPosTable); int saveCursor = cursor; whitespace(); - Markers markers = Markers.EMPTY; - JLeftPadded dimension; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { + if (source.startsWith("[", cursor)) { cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); + return new J.ArrayType( + randomId(), + EMPTY, + Markers.EMPTY, + mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), + annotations, + dimension, + typeMapping.type(tree) + ); } - - return new J.ArrayType( - randomId(), - EMPTY, - markers, - mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), - annotations, - dimension, - typeMapping.type(tree) - ); + cursor = saveCursor; } return baseType; } diff --git a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8JavadocVisitor.java b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8JavadocVisitor.java index f92e26c0093..ebcc3d0f712 100644 --- a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8JavadocVisitor.java +++ b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8JavadocVisitor.java @@ -33,7 +33,6 @@ import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.LeadingBrace; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1076,20 +1075,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) { int saveCursor = cursor; Space before = whitespace(); JLeftPadded dimension; - Markers markers = Markers.EMPTY; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - dimension = JLeftPadded.build(EMPTY).withBefore(EMPTY); - markers = markers.addIfAbsent(new OmitBrackets(Tree.randomId())); - } else { + if (source.startsWith("[", cursor)) { cursor++; dimension = JLeftPadded.build(Space.build(sourceBeforeAsString("]"), emptyList())).withBefore(before); + } else { + cursor = saveCursor; + return elemType; } return new J.ArrayType( randomId(), fmt, - markers, + Markers.EMPTY, elemType, null, dimension, diff --git a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8ParserVisitor.java b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8ParserVisitor.java index 5a445cc375e..e2ee4fa3f0c 100644 --- a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8ParserVisitor.java +++ b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8ParserVisitor.java @@ -32,7 +32,6 @@ import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.internal.JavaTypeCache; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.marker.OmitParentheses; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Markers; @@ -1262,6 +1261,7 @@ private TypeTree arrayTypeTree(Tree tree, Map annotationP JCArrayTypeTree arrayTypeTree = null; while (typeIdent instanceof JCAnnotatedType || typeIdent instanceof JCArrayTypeTree) { if (typeIdent instanceof JCAnnotatedType) { + mapAnnotations(((JCAnnotatedType) typeIdent).getAnnotations(), annotationPosTable); typeIdent = ((JCAnnotatedType) typeIdent).getUnderlyingType(); } if (typeIdent instanceof JCArrayTypeTree) { @@ -1274,22 +1274,11 @@ private TypeTree arrayTypeTree(Tree tree, Map annotationP } Space prefix = whitespace(); - Markers markers = Markers.EMPTY; TypeTree elemType = convert(typeIdent); List annotations = leadingAnnotations(annotationPosTable); - JLeftPadded dimension; - int saveCursor = cursor; - whitespace(); - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { - cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); - } + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); assert arrayTypeTree != null; - return new J.ArrayType(randomId(), prefix, markers, + return new J.ArrayType(randomId(), prefix, Markers.EMPTY, count == 1 ? elemType : mapDimensions(elemType, arrayTypeTree.getType(), annotationPosTable), annotations, dimension, @@ -1307,26 +1296,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map annotations = leadingAnnotations(annotationPosTable); int saveCursor = cursor; whitespace(); - Markers markers = Markers.EMPTY; - JLeftPadded dimension; - if (source.startsWith("...", cursor)) { - cursor = saveCursor; - markers = markers.addIfAbsent(new OmitBrackets(randomId())); - dimension = padLeft(EMPTY, EMPTY); - } else { + if (source.startsWith("[", cursor)) { cursor = saveCursor; - dimension = padLeft(sourceBefore("["), sourceBefore("]")); + JLeftPadded dimension = padLeft(sourceBefore("["), sourceBefore("]")); + return new J.ArrayType( + randomId(), + EMPTY, + Markers.EMPTY, + mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), + annotations, + dimension, + typeMapping.type(tree) + ); } - - return new J.ArrayType( - randomId(), - EMPTY, - markers, - mapDimensions(baseType, ((JCArrayTypeTree) typeIdent).elemtype, annotationPosTable), - annotations, - dimension, - typeMapping.type(tree) - ); + cursor = saveCursor; } return baseType; } diff --git a/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/AnnotationTest.java b/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/AnnotationTest.java index c72358beb45..17855dffbfd 100644 --- a/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/AnnotationTest.java +++ b/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/AnnotationTest.java @@ -16,8 +16,6 @@ package org.openrewrite.java.tree; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.openrewrite.Cursor; import org.openrewrite.ExecutionContext; import org.openrewrite.Issue; @@ -399,29 +397,4 @@ public J.ArrayType visitArrayType(J.ArrayType arrayType, Object o) { ) ); } - - @Issue("https://github.com/openrewrite/rewrite/issues/3881") - @ParameterizedTest - @ValueSource(strings = { - "", - "[]" - }) - void annotatedVararg(String input) { - rewriteRun( - java( - String.format(""" - import java.lang.annotation.ElementType; - import java.lang.annotation.Target; - - class TypeAnnotationTest { - void method(Integer @A1 %s ... integers) {} - - @Target(ElementType.TYPE_USE) - private @interface A1 { - } - } - """, input) - ) - ); - } } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java b/rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java index 60ef1a7840b..f74712242d3 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java @@ -19,7 +19,6 @@ import org.openrewrite.PrintOutputCapture; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.CompactConstructor; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.marker.OmitParentheses; import org.openrewrite.java.tree.*; import org.openrewrite.java.tree.J.*; @@ -182,7 +181,7 @@ public J visitArrayType(ArrayType arrayType, PrintOutputCapture

p) { } visit(type, p); visit(arrayType.getAnnotations(), p); - if (arrayType.getDimension() != null && !arrayType.getMarkers().findFirst(OmitBrackets.class).isPresent()) { + if (arrayType.getDimension() != null) { visitSpace(arrayType.getDimension().getBefore(), Space.Location.DIMENSION_PREFIX, p); p.append('['); visitSpace(arrayType.getDimension().getElement(), Space.Location.DIMENSION, p); @@ -199,14 +198,12 @@ public J visitArrayType(ArrayType arrayType, PrintOutputCapture

p) { private void printDimensions(J.ArrayType arrayType, PrintOutputCapture

p) { beforeSyntax(arrayType, Space.Location.ARRAY_TYPE_PREFIX, p); visit(arrayType.getAnnotations(), p); - if (arrayType.getDimension() != null && !arrayType.getMarkers().findFirst(OmitBrackets.class).isPresent()) { - visitSpace(arrayType.getDimension().getBefore(), Space.Location.DIMENSION_PREFIX, p); - p.append('['); - visitSpace(arrayType.getDimension().getElement(), Space.Location.DIMENSION, p); - p.append(']'); - if (arrayType.getElementType() instanceof J.ArrayType) { - printDimensions((ArrayType) arrayType.getElementType(), p); - } + visitSpace(arrayType.getDimension().getBefore(), Space.Location.DIMENSION_PREFIX, p); + p.append('['); + visitSpace(arrayType.getDimension().getElement(), Space.Location.DIMENSION, p); + p.append(']'); + if (arrayType.getElementType() instanceof J.ArrayType) { + printDimensions((ArrayType) arrayType.getElementType(), p); } afterSyntax(arrayType, p); } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java b/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java index 10b746c6956..2bfe7daa235 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java @@ -19,7 +19,6 @@ import org.openrewrite.PrintOutputCapture; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.marker.LeadingBrace; -import org.openrewrite.java.marker.OmitBrackets; import org.openrewrite.java.tree.*; import org.openrewrite.marker.Marker; import org.openrewrite.marker.Markers; @@ -410,7 +409,7 @@ public J visitArrayType(J.ArrayType arrayType, PrintOutputCapture

p) { beforeSyntax(arrayType, Space.Location.ARRAY_TYPE_PREFIX, p); visit(arrayType.getElementType(), p); visit(arrayType.getAnnotations(), p); - if (arrayType.getDimension() != null && !arrayType.getMarkers().findFirst(OmitBrackets.class).isPresent()) { + if (arrayType.getDimension() != null) { visitSpace(arrayType.getDimension().getBefore(), Space.Location.DIMENSION_PREFIX, p); p.append('['); visitSpace(arrayType.getDimension().getElement(), Space.Location.DIMENSION, p); diff --git a/rewrite-java/src/main/java/org/openrewrite/java/marker/OmitBrackets.java b/rewrite-java/src/main/java/org/openrewrite/java/marker/OmitBrackets.java deleted file mode 100644 index f352afa6936..00000000000 --- a/rewrite-java/src/main/java/org/openrewrite/java/marker/OmitBrackets.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2024 the original author or 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 - *

- * https://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. - */ -package org.openrewrite.java.marker; - -import lombok.Value; -import lombok.With; -import org.openrewrite.marker.Marker; - -import java.util.UUID; - -@Value -@With -public class OmitBrackets implements Marker { - UUID id; -}