Skip to content

Commit

Permalink
Add modifiers to TypeParameter for kotlin (#3698)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 authored Nov 16, 2023
1 parent 42a5017 commit 5d04f64
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ private J.TypeParameter visitTypeParameter(GenericsType genericType) {
.withAfter(EMPTY));
bounds = JContainer.build(boundsPrefix, convertedBounds, Markers.EMPTY);
}
return new J.TypeParameter(randomId(), prefix, Markers.EMPTY, emptyList(), name, bounds);
return new J.TypeParameter(randomId(), prefix, Markers.EMPTY, emptyList(), emptyList(), name, bounds);
}

private J.Wildcard visitWildcard(GenericsType genericType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ public Tree visitParam(ParamTree node, List<Javadoc> body) {
Space.EMPTY,
Markers.EMPTY,
emptyList(),
emptyList(),
visitIdentifier(node.getName(), whitespaceBefore()).withPrefix(namePrefix),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ public J visitTypeParameter(TypeParameterTree node, Space fmt) {
JContainer.build(sourceBefore("extends"),
convertAll(node.getBounds(), t -> sourceBefore("&"), noDelim), Markers.EMPTY);

return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, name, bounds);
return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, emptyList(), name, bounds);
}

private <T extends TypeTree & Expression> T buildName(String fullyQualifiedName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ public Tree visitParam(ParamTree node, List<Javadoc> body) {
Space.EMPTY,
Markers.EMPTY,
emptyList(),
emptyList(),
visitIdentifier(node.getName(), whitespaceBefore()).withPrefix(namePrefix),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ public J visitTypeParameter(TypeParameterTree node, Space fmt) {
JContainer.build(sourceBefore("extends"),
convertAll(node.getBounds(), t -> sourceBefore("&"), noDelim), Markers.EMPTY);

return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, name, bounds);
return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, emptyList(), name, bounds);
}

private <T extends TypeTree & Expression> T buildName(String fullyQualifiedName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ public Tree visitParam(ParamTree node, List<Javadoc> body) {
Space.EMPTY,
Markers.EMPTY,
emptyList(),
emptyList(),
visitIdentifier(node.getName(), whitespaceBefore()).withPrefix(namePrefix),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ public J visitTypeParameter(TypeParameterTree node, Space fmt) {
JContainer.build(sourceBefore("extends"),
convertAll(node.getBounds(), t -> sourceBefore("&"), noDelim), Markers.EMPTY);

return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, name, bounds);
return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, emptyList(), name, bounds);
}

private <T extends TypeTree & Expression> T buildName(String fullyQualifiedName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ public Tree visitParam(ParamTree node, List<Javadoc> body) {
Space.EMPTY,
Markers.EMPTY,
emptyList(),
emptyList(),
visitIdentifier(node.getName(), whitespaceBefore()).withPrefix(namePrefix),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ public J visitTypeParameter(TypeParameterTree node, Space fmt) {
JContainer.build(sourceBefore("extends"),
convertAll(node.getBounds(), t -> sourceBefore("&"), noDelim), Markers.EMPTY);

return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, name, bounds);
return new J.TypeParameter(randomId(), fmt, Markers.EMPTY, annotations, emptyList(), name, bounds);
}

private <T extends TypeTree & Expression> T buildName(String fullyQualifiedName) {
Expand Down
6 changes: 5 additions & 1 deletion rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -5258,6 +5258,10 @@ final class TypeParameter implements J {
@Getter
List<Annotation> annotations;

@With
@Getter
List<J.Modifier> modifiers;

/**
* Will be either a {@link TypeTree} or {@link Wildcard}. Wildcards aren't possible in
* every context where type parameters may be defined (e.g. not possible on new statements).
Expand Down Expand Up @@ -5308,7 +5312,7 @@ public JContainer<TypeTree> getBounds() {
}

public TypeParameter withBounds(@Nullable JContainer<TypeTree> bounds) {
return t.bounds == bounds ? t : new TypeParameter(t.id, t.prefix, t.markers, t.annotations, t.name, bounds);
return t.bounds == bounds ? t : new TypeParameter(t.id, t.prefix, t.markers, t.annotations, t.modifiers, t.name, bounds);
}
}
}
Expand Down

0 comments on commit 5d04f64

Please sign in to comment.