Eclipse search Tips
- Published: 17 January 2013
Want to have everything at your fingertips with Eclipse ? this tutorial provides some handy tips to search and find what you are looking for in Eclipse.
How to search in a specific Eclipse project
If you have lots of open projects in your workspace then you would like to search in a specific project.
Solution: Create a working set . Working sets group elements for display in views or for operations on a set of elements.
Open the Search Menu and click on the "Choose" button to create a new Working Set:
Next, choose New to create a new Working Set :
In the next screen, select "Resource":
Pickup one or more projects from your Workspace which will be part of your Working Set:
Now you can use the New Working set in your Searches:
How to search for a class/package in a set of JAR files?
Provided that you are using the JAR files in a project as a library, then you can use the powerful Java search. Here's for example how to find where the org.apache.cxf.Bus class is contained :
Depending on what is searched for, the search string should describe the element:
Type: the type name (may be qualified or not).
Method: the defining type name (may be qualified or not as for Type search, optional), the method selector and its parameters
Example: org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(MementoTokenizer, WorkingCopyOwner)
Package: the package name for a package (e.g. org.eclipse.jdt.internal.core
Constructor: the defining type name (may be qualified or not as for Type search, optional) and the constructor parameters
Example: org.eclipse.jdt.internal.core.JavaElement(JavaElement, String)
How to find all classes that extend interface
Simply use Ctrl-T to get the descendants and then Ctrl-T again if super interfaces/classes are wanted:
How to replace String in all files in Eclipse
Not everybody is aware that you can perform safe Search and Replace string patterns across a set of files. I mentioned "safe" because you are allowed to preview changes before executing the replace.
- Go to the Menu "Search"->"File"
- Enter text, file pattern and projects
- Click "Replace"
- Enter new text
How to exclude folders from Eclipse search
The simplest way to exclude a folder is: right click on a folder, go to properties, and mark a folder as derived. Derived
How to share the eclipse search result/ query
Have a look at the Mylyn project (http://eclipse.org/mylyn).
Mylyn is the task and application lifecycle management (ALM) framework for Eclipse. It allows you to create tasks and send them to co-workers through a task repository (such as bugzilla, jira, or most major issue trackers). Attached to these tasks are "contexts", which associate code elements (methods, fields, classes, etc) with the task.
Here are the steps needed to get started:
- Install mylyn (you and all co-workers)
- Install the proper Eclipse Connector for your issue tracker (such as SVN Eclipse connector).
- Now add the task repository to your Eclipse. This is the way that mylyn speaks to your issue tracker. It allows you to create issues, bug reports, tasks, etc, from within Eclipse.
- With this set up, you can now create a task associated with a task repository and activate it. You can add the desired program elements to your task by right clicking -> Mark as Landmark.
How to export/save Search Results
Out of the box there is no Save search functionality, however you can use the "Show Previous Searches" button at the top of the search console. It has a flashlight with a list above it. You can toggle between searches and Eclipse has already done all the heavy work.