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?

Makoto
  • 104,088
  • 27
  • 192
  • 230
Valentin Milea
  • 3,186
  • 3
  • 28
  • 29
  • I'm missing that one amazing feature of eclipse as well. Can't say I'm missing much else in IntelliJ. – xor_eq Dec 01 '11 at 17:07
  • IntelliJ also implements this, but it only works from methods.?? your question if wrong it only works for fields – Jaime Hablutzel May 10 '12 at 00: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 '14 at 11:08

4 Answers4

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).

machinery
  • 3,793
  • 4
  • 41
  • 52
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.

ric-salmon
  • 108
  • 1
  • 6
  • 1
    Once you login to youtrack, and click on the issue, there is a vote link on the bottom right. – ric-salmon Oct 25 '17 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 '19 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?

Pakka Pakka
  • 2,046
  • 15
  • 9
  • 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) – Valentin Milea Jan 03 '12 at 14:27
0

Use "Find Usages" feature (Alt+F7)

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