Ryan
Ryan

Reputation: 604

How can you use structural search to find constructor calls for subclasses of a given type?

I have an abstract class called "com.foo.BaseFoo"

I want to find anyone that calls new() on anything that extends from BaseFoo

I've tried doing a search template of:

new $BaseFoo$()

and then edited the variables to have an expression constraint on the type of the object to be

com.foo.BaseFoo

and clicked on the "Apply constraint within type hierarchy" but this hasn't worked.

Upvotes: 3

Views: 1125

Answers (1)

Bas Leijdekkers
Bas Leijdekkers

Reputation: 26482

You were almost there. Use a template like the following:

new $BaseFoo$($argument$)

Where $BaseFoo$
Text/regexp: com\.foo\.BaseFoo
check Apply constraint within type hierarchy

and $argument$
minimum count: 0 maximum count: unlimited

Upvotes: 5

Related Questions