Skip to content

Commit

Permalink
Merge branch 'InterimProcessorSet' into 'master'
Browse files Browse the repository at this point in the history
JDK 17: InterimProcessor#ALLOWED_CLASS_TREE_KINDS uses EnumSet

See merge request exedio/cope!1239
  • Loading branch information
rw7 committed Sep 16, 2024
2 parents b94d5ef + 2430a1c commit 2051d43
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions instrument/src/com/exedio/cope/instrument/InterimProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Deque;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
Expand All @@ -71,12 +72,12 @@

final class InterimProcessor extends JavacProcessor
{
private static final Set<String> ALLOWED_CLASS_TREE_KINDS = new HashSet<>(asList(
Tree.Kind.CLASS.name(),
Tree.Kind.INTERFACE.name(),
Tree.Kind.ENUM.name(),
Tree.Kind.RECORD.name()
));
private static final Set<Tree.Kind> ALLOWED_CLASS_TREE_KINDS = EnumSet.of(
Tree.Kind.CLASS,
Tree.Kind.INTERFACE,
Tree.Kind.ENUM,
Tree.Kind.RECORD
);

private final Path targetDirectory;
private final Params params;
Expand Down Expand Up @@ -538,11 +539,11 @@ private static String getMethodDeclaration(final ExecutableElement method, final

private static String getTypeToken(final ClassTree ct)
{
final String name = ct.getKind().name();
if (ALLOWED_CLASS_TREE_KINDS.contains(name))
return name.toLowerCase(Locale.ROOT);
final Tree.Kind kind = ct.getKind();
if (ALLOWED_CLASS_TREE_KINDS.contains(kind))
return kind.name().toLowerCase(Locale.ROOT);
else
throw new RuntimeException(ct.getKind().name());
throw new RuntimeException(kind.name());
}

private boolean currentClassIsFeatureContainer()
Expand Down

0 comments on commit 2051d43

Please sign in to comment.