Is there a way in IntelliJ to make a usage search of a method and filter this by specific arguments passed to the method?
-
09-07-2021 - |
Question
I have a method in my Service class which executes an hibernate update for any domain object:
update(Object obj)
It's called from lot's of classes in my project for different kind of objects. I would like to find all usages of this method when it's called for a specific domain object. I.e. call methods call wich executes an update of my Title object:
serviceClass.update(Title title)
I'm using IntelliJ as my IDE and I'm wondering if there is a way to find all those usages. Does anyone have an IDEA how to do this?
Thanks a lot in advance, Ronny
Solution
I've tried it with a small sample project and was able to achieve the desired behavior using Structural Search and Replace feature with the modified method calls
template:
$MethodCall$
Text constraints, Text/regexp should be set to update
so that methods with other names are ignored. $Parameter$
Occurrences count, Minimum count should be set to 1
to ignore method calls with no or more parameters.
Results:
OTHER TIPS
If you're interested in the call chains that are providing a specific input into a given method, try the Analyze->Data Flow to Here command.
This allows you to see which values are passed in, through which call chains. And, for example, where null values might be coming from.
Quite a powerful feature, really.