Constraint for enum in structural search and replace

What constraints in strutural search and replace I must use to match an enum?
I want to find all java.util.Map whose key is an enum. So I have in the search searchtemplate "Map<$keyClass$, $valueClass$> $mapName$ = new HashMap();".
For keyClass I tried the expression constraint "Text/regexp constraint for java expression type" with the value "enum" but without success.

Comment actions Permalink

Hi Otto,

To find all Map declarations where the key is of an enum type use the following Structural Search query:

$M$<$E$, $V$>
E Text/regexp: Enum (all enums extend java.lang.Enum implicitly)
Apply constraint within type hierarchy
M Text/regexp: Map
Apply constraint within type hierarchy (to also find HashMap and such)

Sorry for the late answer, hope it still helps,
Comment actions Permalink

Thank you! The implicitly inheritance from java.lang.Enum I didn't have realised.


Please sign in to leave a comment.