Skip to content

Commit

Permalink
fix: remove unused variable (#324)
Browse files Browse the repository at this point in the history
* fix: remove unused variable

* feat: apply setOf to copy with multiple arguments
  • Loading branch information
SimonVerhoeven authored Oct 22, 2023
1 parent ab08480 commit 512712c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
if (isAssignmentSetOfEnum(type)) {
maybeAddImport("java.util.EnumSet");

StringJoiner setOf = new StringJoiner(", ", "EnumSet.of(", ")");
List<Expression> args = m.getArguments();
StringJoiner setOf = new StringJoiner(", ", "EnumSet.of(", ")");
args.forEach(o -> setOf.add("#{any()}"));
return JavaTemplate.builder("EnumSet.of(#{any()})")

return JavaTemplate.builder(setOf.toString())
.contextSensitive()
.imports("java.util.EnumSet")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public enum Color {
RED, GREEN, BLUE
}
public void method() {
Set<Color> warm = Set.of(Color.RED);
Set<Color> warm = Set.of(Color.RED, Color.GREEN);
}
}
""",
Expand All @@ -57,7 +57,7 @@ public enum Color {
RED, GREEN, BLUE
}
public void method() {
Set<Color> warm = EnumSet.of(Color.RED);
Set<Color> warm = EnumSet.of(Color.RED, Color.GREEN);
}
}
"""
Expand Down

0 comments on commit 512712c

Please sign in to comment.