Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search in source attachment in Eclipse [duplicate]

Tags:

eclipse

Is there a way to search inside one particular source attachment in Eclipse?

Currently what I am doing is:

  1. In Eclipse, right-clicking on the binary jar that I'm interested in the source code of, in Package Explorer, and choosing Properties
  2. Copying and pasting the source attachment filename from the dialog box
  3. Making a new directory
  4. Unzipping the sources jar to that directory
  5. Searching that directory in Emacs (yes, Emacs - this means I don't have to add it as a new project in Eclipse)

There must be an easier way!

like image 780
Robin Green Avatar asked May 26 '26 04:05

Robin Green


1 Answers

Is there a way to search inside one particular source attachment in Eclipse?

The answer to your question is: no, not directly. See Eclipse bugs #199994 and #23341.

I hope the bounty is meant to be for the correct answer, even though it might not be the answer you had hoped for.

A workaround you can always use if at least you want to avoid using two tools (Eclipse vs. Emacs) is to

  • create a dummy project, e.g. "JDK6 (dummy)",
  • deactivate the Java builder in its project properties so as to avoid an automatic build you do not want and which might fail due to missing dependencies anyway,
  • unzip the source attachment (e.g. source.zip) into the dummy project's src folder,
  • select the project or one of its packages in package explorer and
  • search happily via Ctrl-H using text or Java search, maybe using the search option "Scope: Selected resources" (attention: initial indexing for big sources like JDK during the very first search action can take a while, the next time it will be much faster).

I just tested this, and it works nicely. :-)

Optionally you may even select the dummy project's src folder as the source location for your library. This could speed up things like "Open declaration" via F3 in comparison with unzipping a source JAR/ZIP.

like image 157
kriegaex Avatar answered May 27 '26 22:05

kriegaex