How to find usages using Eclipse IDE?

JavaEclipse

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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)

Solution 2 - Java

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

Open call hierarchy, open inheritance hierarchy.

Solution 3 - Java

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

Solution 4 - Java

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

Also works on methods, variables etc.

Solution 5 - Java

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.

Solution 6 - Java

For Mac, press cmd + Shift + G

Solution 7 - Java

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongstackoverflowView Question on Stackoverflow
Solution 1 - JavaPranaleeView Answer on Stackoverflow
Solution 2 - JavaVinit PrajapatiView Answer on Stackoverflow
Solution 3 - JavamaoyangView Answer on Stackoverflow
Solution 4 - JavapaulView Answer on Stackoverflow
Solution 5 - JavaNileshView Answer on Stackoverflow
Solution 6 - JavaDanilo RaspaView Answer on Stackoverflow
Solution 7 - JavaKarthikView Answer on Stackoverflow