How to search a keyword in Eclipse type search - eclipse

How can I do a keyword search in Eclipse Types.
When doing a search using the eclipse, the system is doing the search in all the java files I have in my workspace but does not do a search in the classes I have in the JARs I have in my workspace.
Following is the search term:
Cannot initialize the modules because I can't guess which module to mount
to '/' at edu.mit.simile.butterfly.Butterfly.wireModules(Butterfly.java:821)
I tried doing this, but of no use. For better understanding attaching the images:
I can't figure out from which jar file type, this string is coming. As we can do a global search on the .java files. Is there a way, we can do keywood search for the jar types(jar file content .class) as well in Eclipse.
Or that is not even possible as suggested by #nitind.

It's not clear what you mean by "a keyword search in Eclipse Types". If I had to guess, I think you mean that you're looking for a type that has a particular word in the name.
You can do this by first doing the "Open Type" operation from the menu bar or from a keyboard shortcut. For example, if you want to find all of the types that have "Basket" in the name of the type, then enter "Basket" in the search field in the "Open Type" dialog.

Currently there is no Eclipse plugin/configuration/setup that can perform this operation.
Although it is possible to search a jar by writing a simple utility like this:
URL url = FindResourceMain.class.getResource("/" + filePath);
We can also use, utility tools like Total Commander to perform a global search in jar/zip.

Related

Is it possible to set open resource (ctrl-shift-R) to search full path by default in Eclipse IDE?

When using editor like atom or sublime, when trying to open resource by hot key (e.g. ctrl-P in atom), the default behavior is to search in full path. For example, when I press ctrl-P and type controller/base_controller, I will see controller/base_controller.php in the search result.
However, in Eclipse, when I press ctrl-shift_R and type controller/base_controller I will get nothing. I will need to type base_controller (if the file name is not repeating much) or *controller/base_controller to have controller/base_controller.php in the search result.
When most OS prohibit using slash ('/') in file name, I would expect Eclipse should at least know it is a full path search when I input slash. Anyway, is there a way I can set the "open resource" search to be full path search by default in Eclipse IDE?
In Eclipse a full path starts with /.
So in your example, you have to type /controller/base_controller to match base_controller.php in the project controller.
Alternatively, you can select the project or folder and use the File Search (Ctrl+H) leaving the Containing text field empty, with a file pattern and choosing the selected project or folder as scope.

In Eclipse, how can you search within a search result?

"Long live the Unix Pipes".
Since I am working with Eclipse IDE, I would like to perform search within search results. Is that possible? How can I do that?
Ex:
Search for references of User (class).
> Search for validation in this result.
> Finally, search for specific pattern.
This is possible in Eclipse, well as far as the version I am using which is Eclipse Juno 4.2.2; I've used this extensively for impact analysis.
For example:
Search using "File Search" with criteria "employee"
The results will appear in the Tab "Search", assuming you are in the tree view (by default), click the root folder
Again, use the "File Search" this time using the 2nd criteria, for example "default" and making sure to click the Selected resources radio button
Effectively, this searches the keyword "default" from the previous search results produced by searching "employee".
Is it really required?. If you are searching any key in the search results then why don't you use it as search key in previous search itself?.
Eclipse search supports regular expression so you can use multiple search words likes key1 or key2 or key1 and key2 etc to narrow the search results.
Refer this Eclipse File Search Dialog - Regular Expression for Group Unions and Negation
However
You can search in search results with the help of some plugins check here. Take a look at Insta search and glance(Suites for your need) plugin.
Search result can also be exported with the help of this plugin
You cannot. And I am 99% sure of this.
But, just for your info, you can do reference search by pressing Cntrl + G on class name, or method name.

How to avoid repeated matching items in Eclipse 'Open Resource'?

The project I'm working in uses Maven and its typical standar directory layout.
When I look for a resource with Eclipse 'Open Resource' I get these matches:
Where I get repeated matches.
There are only 2 XML files in filesystem.
The one under src/ and the one under target/.
For example, the path to the src/ file is:
maindev/common/utils/persistence/src/main/resources/com/ericsson/m2m/common/utils/persistence/impl/mybatis/custom/xml/
But 'Open Resource' indicates 3 matches for the same file with relative paths:
maindev/common/utils/persistence/src/...
common/utils/persistence/src/...
persistence/src/...
Is there a way in Eclipse to avoid those repeated matches?
Moreover, is there a way in Eclipse to indicate not to return resources for target/ directories?
NOTE: I tried Wojtek O. suggestion, but still getting matches:
You see multiple files because they logically are contained withing difference Eclipse projects. You could try to close some of those projects but that may as well result in compilation errors. If you wish to hide some files from the Open Resource... dialog you need to mark the folder containg those files as derived by right clicking on it in the Project Explorer and selecting Derived checkbox under Attributes section.
This is a really old thread, but in the newer Eclipse versions (Photon+) there's a filter option for resource search.
On the Open Resource dialog (Ctrl+Shift+R), click the drop-down on top "Enter resource name prefix..." and select "Filter Duplicated Resources".
If you're just looking for Java classes you can also use Open Type dialog (CTRL-Shift-T).

Eclipse searching files in specific package

I am attempting to strip out my Log.i Log.d etc code in eclipse. I have used them liberally. I can find them by control+h and using the File Search tab. Once I can filter the results to a certain package I plan on doing a replace with a blank string.
I check the Regular Expression checkbox.
In the Containing text: field I use Log\..*;
This gets every single Log line of code in the workspace (At least I think workspace, because there is currently 1 project in the workspace)
How can I get this search to only search within a certain package (ie com.example.so.is.super.cool)
I assume this is in the File name patterns field and I have attempted:
.*super.*
*super*
super
Please let me know if there is a pattern I can enter in File name patterns that narrows the search down for me.
Here's how:
Select the package in Package Explorer
On the Search > File Search panel: Specify regular expression, set Scope to "Selected resources"
Press Search

Best way to search for instances of a string in Eclipse

I am trying to find where a particular variable is being set. Is it possible to search through a set of project source files to find all the possible spots a certain variable might be getting set?
The search in the drop-down menu is a bit confusing to use. After I enter a search I happen to be looking at, and I know it is there, when I do a search from the root of the file system, it tells me that the string is not there :)
Is this a common newbie issue? I just recently started using Eclipse and could just be missing something simple :)
Thanks,
Alex
Select the field where it is declared, then ctrl+shift+H to open the search dialog. The "Java Search" tab should be selected with the Search string populated with your field name, including package. In "Search For" select "Field" and in "Limit To" select "Write accesses" That will show you everywhere that field is assigned.
Here's a screenshot of the search dialog.
I believe the default mapping is Ctrl Shift G.
Highlight the variable and do Ctrl Shift G it will find all references of that variable.
Be careful, it will not just do assignments, so you might be getting more data than you want.