28

Eclipse JDT has a 'call hierarchy' feature -- start from a field/method and it recursively finds all references.

IntelliJ also implements this, but it only works from methods. For fields, you can only 'Find Usages', so if you want to dig deeper you have to do additional searches.

Tried 'Dataflow to here', but it's not what I'm looking for.

Am I missing something? Is there a better way to explore field usage in IntelliJ?

3
  • I'm missing that one amazing feature of eclipse as well. Can't say I'm missing much else in IntelliJ.
    – xor_eq
    Dec 1, 2011 at 17:07
  • IntelliJ also implements this, but it only works from methods.?? your question if wrong it only works for fields May 10, 2012 at 0:40
  • I'm missing that feature, too. Additionally, in eclipse you could Expand with Constructors in hierarchy view, which is a very powerful feature. Miss that very much!
    – sulai
    Nov 12, 2014 at 11:08

4 Answers 4

13

Select the method you're interested in and then use from the top menu "Navigate > Call Hierarchy" or simply Ctrl+Alt+H.

AFAIK this doesn't work for fields, because when I select a field, the "Navigate > Call Hierarchy" option becomes grayed-out. The only similar featutes I'm aware of for fields are "Edit > Find > Find Usages" (Alt+F7) and "Edit > Find > Show Usages" (Ctrl+Alt+F7).

2
  • 1
    It doesn't work on fields, and it's quite clear in the asked question.
    – Toilal
    Nov 30, 2014 at 7:20
  • @Toilal edited the answer to address your concern, please have a look.
    – machinery
    Dec 2, 2014 at 16:18
9

EDIT

The issue below has been resolved and IntelliJ IDEA 2019.3 will have this feature.

EDIT 2

I downloaded:

IntelliJ IDEA 2019.3 EAP (Community Edition)
Build #IC-193.3793.14, built on September 25, 2019

But it seems this issue was not fixed correctly, the call hierarchy for fields does not take you to the actual usage of the field in the method rather to the line of the method definition.

See: https://youtrack.jetbrains.net/issue/IDEA-160274#focus=streamItem-27-3721096.0-0

Original answer

IntelliJ doesn't have this feature, however there is a feature request here: https://youtrack.jetbrains.com/issue/IDEA-160274

If you would like the feature implemented, you can vote there.

2
  • 1
    Once you login to youtrack, and click on the issue, there is a vote link on the bottom right.
    – ric-salmon
    Oct 25, 2017 at 19:07
  • This is the biggest thing I've missed coming from Eclipse so many years ago and it's great to finally be getting it.
    – karmakaze
    Sep 28, 2019 at 16:42
1

"Dataflow to here" and "Dataflow from here" give you a recursive view of data flowing in to, and out of, fields (or local variables).

I think that these two features, in fact, are what you're after. If not, can you rephrase the question in less IDE-specific terms? In other words: what information do you want to extract from your codebase?

1
  • 1
    Let's say I have a member field and want to know all of the code that can touch it. I invoke the call hierarchy view, which initially shows the methods accessing it. Then I should be able, without leaving this view, to drill further into each method's callers. (To make this manageable, the IDE searches for a node's accessors only when it is expanded by the user) Jan 3, 2012 at 14:27
0

Use "Find Usages" feature (Alt+F7)

1
  • 5
    The problem is that "Find Usages" isn't recursive, as Eclipse's call hierarchy is. That makes "Find Usages" far less useful. Nov 1, 2011 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.