56

I have following code:

public class MyClass{
   ...
}

At same workspace I have following class

public class AnotherClass{
   @Autowired
   MyClass myClass;
   ...
}

If I click right mouse button on MyClass(first mentioned) and select "open call hierarchy" I don't see anything.

How to find this usage in Eclipse?

Dave Jarvis
  • 29,586
  • 38
  • 176
  • 304
gstackoverflow
  • 34,819
  • 98
  • 304
  • 641

7 Answers7

84

PC:

  1. Select a word (class name, method name, variable name, etc.)
  2. Press Ctrl+Shift+G

Mac:

  1. Select a word (class name, method name, variable name, etc.)
  2. Press Alt+Cmd+G (++G)
Gerold Broser
  • 13,129
  • 4
  • 41
  • 97
Pranalee
  • 3,189
  • 3
  • 20
  • 36
41

Right click on Myclass, find references in project|workspace.

Open call hierarchy, open inheritance hierarchy.

Alex.K.
  • 3,870
  • 14
  • 43
  • 49
Vinit Prajapati
  • 1,571
  • 1
  • 17
  • 29
  • 1
    How do I find usages of a non java file in my project ? For example properties files, json files etc ? – MasterJoe Nov 20 '17 at 22:19
19

For your case, I think both of (Ctrl +Shift+G) and (Ctrl +Alt+H) work.

To make it more clear:

  • (Ctrl +Shift+G) is shortkey for Search->References->workspace

  • Ctrl +Alt+H is short key for Call hierarchy.

Some other useful short keys like:

  • (Ctrl+G) : Search->Declaration->worksapce
  • (Alt+Left) : Back position
  • (Alt+Right) : Forward position
maoyang
  • 999
  • 1
  • 10
  • 11
5

Try right-click on MyClassand then References->Workspace. I think this might be what you're looking for.

Also works on methods, variables etc.

paul
  • 13,048
  • 23
  • 80
  • 139
2

Select the resource (method name, class name ) & right click . You will find a menu with title 'Open Call Hierarchy' (shortcut key : alt + Ctrl + H ). This will enlist all the usage in project.

Nilesh
  • 133
  • 3
  • 10
0

For Mac, press cmd + Shift + G

Danilo Raspa
  • 755
  • 5
  • 5
0

To my knowledge, both of Ctrl+Shift+G and Ctrl+Alt+H should work.

For Your Information:

Ctrl+Shift+G --> is the short key for Search --> References --> workspace

Ctrl+Alt+H --> is the short key for Call hierarchy.

mature
  • 739
  • 1
  • 11
  • 22
Karthik
  • 105
  • 1
  • 2
  • 11