Is there a way in IntelliJ to make a usage search of a method and filter this by specific arguments passed to the method?

StackOverflow https://stackoverflow.com/questions/12972270

문제

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

도움이 되었습니까?

해결책

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:

enter image description here

$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:

results

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top