9

I have parent class Parent with method getToken(). And I have its child class - ChildA and ChildB, which don't override method getToken().

How I can search usages of method getToken() which used by instance of class ChildA?

Sorry for my English. Thanks!

3 Answers 3

12

As I spent half an hour to find the exact solution through all complicated and outdated documentations and examples, I just put the full answer using SSR here (Intellij 15.0.5):

Open SSR dialog (Edit > Find > Search Structurally...) and input template in screenshot, then click on "Edit variables..." to see the second dialog and edit the "Expression type (regexp)" as shown:

enter image description here

and if you want to include subclasses of ChildA too, just check the box "Apply constraint within type hierarchy" bellow the expression type:

enter image description here

1
  • Can't believe this only has one upvote. Really useful example. Thanks!
    – fragorl
    Commented Mar 7, 2018 at 23:27
5

You can add getToken() to ChildA, perform the search only for this method, then delete it. Another way is to use Structural Search and Replace.

1

Intellij asks about this if you use Ctrl+Alt+Shift+F7 for the search. First you have to explicitly override the method in the subclass/subinterface though, as CrazyCoder suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.