3

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.

Ryan
  • 584
  • 3
  • 13
  • when you write call 'new()' does it mean to call the method new() on the BaseFoo class hierarchy or is it related to the BaseFoo constructor ? – F. Geraerts Jul 25 '13 at 15:07
  • Idealy I'd like to find things where say we had Foo and Boo that extends com.foo.BaseFoo, and in the code I'd want the structural search to find "new Foo()" or "new Boo()" – Ryan Jul 26 '13 at 15:58

1 Answers1

5

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

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68