3

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!

Robin Green
  • 32,079
  • 16
  • 104
  • 187

3 Answers3

6

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.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
3

Recently discovered the following plugin has beta support for searching into linked source jars: https://code.google.com/a/eclipselabs.org/p/instasearch/

You have to enable searching source jars in the preferences as it is turned off by default. Depending on how much source you have, the indexing process is very slow, but then search is very fast.

I have an Eclipse workspace with the enterprise versions of Alfresco (Explore, Share and SOLR) and Alfresco Workdesk (Vanilla, Office and Mobile). Indexing took about 8 minutes on my Early 2011 MacBook Pro. Search is almost instantanious.

user2757811
  • 191
  • 2
  • 4
0

Yes, you can do this with the m2eclipse plugin in conjunction with a Java Maven project. A demonstration of this in action starts at around 2:30 in this video. Once you have the source code downloaded, you can search the source with the normal Eclipse search function under:

Search -> File... -> File Search.

If you need an nice intro to Maven, Eclipse, and the m2eclipse plugin check out this link.

herrtim
  • 2,697
  • 1
  • 26
  • 36