Skip to content

Commit

Permalink
Revert "Added support for annotated varargs. (#3882)"
Browse files Browse the repository at this point in the history
This reverts commit a26ec03.
  • Loading branch information
knutwannheden committed Jan 4, 2024
1 parent a26ec03 commit 791748d
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1155,20 +1154,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) {
int saveCursor = cursor;
Space before = whitespace();
JLeftPadded<Space> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1282,22 +1281,11 @@ private TypeTree arrayTypeTree(Tree tree, Map<Integer, JCAnnotation> annotationP
}

Space prefix = whitespace();
Markers markers = Markers.EMPTY;
TypeTree elemType = convert(typeIdent);
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
JLeftPadded<Space> 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<Space> 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,
Expand All @@ -1315,26 +1303,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map<Integer, JCAnno
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
int saveCursor = cursor;
whitespace();
Markers markers = Markers.EMPTY;
JLeftPadded<Space> 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<Space> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1160,20 +1159,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) {
int saveCursor = cursor;
Space before = whitespace();
JLeftPadded<Space> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1359,22 +1358,11 @@ private TypeTree arrayTypeTree(Tree tree, Map<Integer, JCAnnotation> annotationP
}

Space prefix = whitespace();
Markers markers = Markers.EMPTY;
TypeTree elemType = convert(typeIdent);
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
JLeftPadded<Space> 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<Space> 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,
Expand All @@ -1392,26 +1380,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map<Integer, JCAnno
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
int saveCursor = cursor;
whitespace();
Markers markers = Markers.EMPTY;
JLeftPadded<Space> 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<Space> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1159,20 +1158,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) {
int saveCursor = cursor;
Space before = whitespace();
JLeftPadded<Space> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1357,22 +1356,11 @@ private TypeTree arrayTypeTree(Tree tree, Map<Integer, JCAnnotation> annotationP
}

Space prefix = whitespace();
Markers markers = Markers.EMPTY;
TypeTree elemType = convert(typeIdent);
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
JLeftPadded<Space> 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<Space> 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,
Expand All @@ -1390,26 +1378,20 @@ private TypeTree mapDimensions(TypeTree baseType, Tree tree, Map<Integer, JCAnno
List<J.Annotation> annotations = leadingAnnotations(annotationPosTable);
int saveCursor = cursor;
whitespace();
Markers markers = Markers.EMPTY;
JLeftPadded<Space> 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<Space> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1076,20 +1075,18 @@ public J visitArrayType(ArrayTypeTree node, Space fmt) {
int saveCursor = cursor;
Space before = whitespace();
JLeftPadded<Space> 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,
Expand Down
Loading

0 comments on commit 791748d

Please sign in to comment.