Jeff Axelrod
Jeff Axelrod

Reputation: 28188

How can I find references to an external class without source code in Eclipse?

Is there a straightforward way to find references in my code to a class in an external library (jar without source) if I don't already have a file open that has a reference to the class?

For instance, say I want to find all references in my code to System.out.println() but I don't already have code open that uses println. How can I do this?

Upvotes: 1

Views: 358

Answers (3)

Ashutosh Jindal
Ashutosh Jindal

Reputation: 18869

It would be possible to do this using a File Search. Press Ctrl + H and put in System.out.println. Adjust the scope of the search according to your needs (I usually set it to Enclosing Project or Selected Resource).

Upvotes: 0

E-Riz
E-Riz

Reputation: 32914

You can open any type (class or interface) via Ctrl+Shift+T (Command+Shift+T on a Mac). When the class/interface source opens, select a method or field (instance variable) in that class, right-click, and choose References.

If you don't have the source code, you'll see the Class File Editor, "Source not found" window. If you don't already have the "link with editor" icon enabled, either enable it or select the Navigate menu, Show In, Package Explorer. Then in the package explorer, select a method or field (instance variable) in that class, right-click, and choose References.

Upvotes: 1

Jeff Axelrod
Jeff Axelrod

Reputation: 28188

The only way I know to do this is to perform the following (not exactly straightforward) sequence:

  1. Open and edit an existing class by adding a reference to, say, System.out.println()
  2. Organize imports (ctrl-shift-o)
  3. Place the cursor on println and type ctrl-shift-g or search, references, workspace.
  4. Close the class without saving it.

Upvotes: 0

Related Questions