Search code examples
javaparsingintellij-ideacall-hierarchy

How can we programmatically get call hierarchy for methods in IntelliJ


Getting call hierarchy is easy in IntelliJ. Simply use the built in tool. But is there a way to do it using code? Eclipse internal JDT has two classes called CallHierarchy and MethodWrapper that help to do so: link

If there is no equivalent in IntelliJ, is there another pre-built way I can find all callers of a specific method (and base methods)? (Can we programmatically invoke Find Usages?)

In short, for a specific method, I'd like to get all other methods and classes that use the base method in a Collection<> of some sort.

Thanks in advance for any responses or ideas.


Solution

  • Yes, it's possible. After research and a bunch of asking around, the IntelliJ developers pointed me at the IntelliJ Platform SDK... Didn't know this existed. This link in particular points out how to use Find Usages in the SDK. Hope this helps someone in the future.