Question

I need to do important refactoring in a framework. I have a method called about 300 times from various locations in the code (i.e. Find Usages give me about 300 results).

I would like to filter those results so that it only return usages that are not in the body of a constructor.

I tried to use "view call hierarchy", it gives more readable results (i.e. it's more easy to identify call from outside constructor). But I was wondering if there is a way to exclude automatically calls that are done from within a constructor body?

I'm not used to work with the "structural search", but it's maybe something that can help ?

I'm using IDEA EAP 12

Was it helpful?

Solution

(Answering my own question)

I tried to explore features of SSR and finally found an helpful pattern.

What I want : find all calls to method myMethod that are done, but excluding those that are done inside constructor body (i.e. only those that are done in a regular instance method).

The search pattern:

class $Class$ { 
    $ReturnType$ $MethodName$($ParameterType$ $Parameter$) {$MethodCode$;}
}

This pattern will match all non empty methods. So I still have to restrict $MethodCode$ with a regexp:

.*\.myMethod\(.*

I think it should be possible to improve $MethodCode$ regexp, but I didn't get any false match... so I'm happy with that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top