Search code examples
javaeclipseintellij-ideaideinvocation

Can modern IDE detect field/method usage in subtree?


I often meet following problem:

I have following code:

void  rootMethod(){
    C c = method1(a,b);
    method2(c);
}

C looks like this:

class C{
   Type1 param1;
   Type2 param2;
}

I want to find all places where inside method2 and all methods are invoked in this method(recursively in deep) uses c.param1 field.

enter image description here

UPDATE

enter image description here enter image description here


Solution

  • I can suggest you Ctrl-Alt-H in eclipse. This is the closest option to what you need. Press this shortcut on your field and you will see all call hierarchies that Eclipse can see. Then select the root element in hierarchy, right click and choose "Copy Expanded Hierarchy". Paste this into text editor. Now search for method2.