Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ: find code path between two methods

I have two methods in my code base. I would like to figure out, if there exists a path in which one will be called from the other. Is there some way to achieve this easily in IntelliJ without digging manually through call hierarchies?

like image 510
gruszczy Avatar asked Jan 17 '16 17:01

gruszczy


2 Answers

The following might work for you on IntellIJ IDEA 16 and higher. It uses call hierarchies, but automates the digging;-)

  • invoke Call Hierarchy Ctrl+Alt+H on method 1.
  • click on the Callee Methods Hierarchy button in the tool window that appears to show all methods that are called by method 1.
  • click on the Expand All button a couple of times to show called methods until the desired depth.
  • Invoke Find Usages on method 2 and select the Scope Hierarchy 'Callees of 1'

Result: all calls of method 2 in method 1's call hierarchy.

like image 117
Bas Leijdekkers Avatar answered Sep 30 '22 15:09

Bas Leijdekkers


I've done the following:

  • Select method 2 and invoke call hierarchy with Ctrl+Alt+H.
  • Click Expand All on the hierarchy panel
  • Click inside the hierarchy panel, and start typing the name of method 1
like image 39
wwesantos Avatar answered Sep 30 '22 15:09

wwesantos