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

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.

Related

How to search a keyword in Eclipse type search

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.

Is there any way in vscode to know where the current the file has been imported?

Are there any extensions/features in vs-code which could let me know where the current file is imported? I usually do a global search of the filename but it is time consuming when the file name is similar to any variable or there are similar named files.
You can do a right-click on every function / variable or class. Then you choose "Find all references" to show where each function / variable or class is called.
For this you do not need an extension, because it is a standard feature of vscode
- find unused exports in project:
you can use this extension in vscode to find all unused exports
+ find name references (e.g. used exports) in project:
click on name then press shift+alt+F12
NO EXTENSION REQUIRED
Yes, We can find the references of a file in VSCODE like this:
Right-click on the file and then select Find References.
VSCODE will show all the references/imports of the file.
image reference
Right-click > Go to References (Shift + F12)
There is also an extension to change the appearance of how references show https://marketplace.visualstudio.com/items?itemName=jrieken.references-plusplus
If you are limiting your search to the current open workspace / folder, you can
do a search for 'import' using the magnifying glass or pressing ctrl+shift+s
open the results in editor by either clicking the link that says 'Open in editor' or by pressing alt+enter
In the document that opens, search for the name of your module.
In this way you will discover all of the imports that involve your module, regardless of whether you have used 'import mymodule' or 'from mymodule import myfunction' or anything else. I'm specifically thinking of how I'd structure a python project, but if you are using another language, you can alter the search in a way that works for the way your language does imports.

How to exclude .class files from file search in Eclipse?

I want eclipse to ignore all .class files when I search for a keyword in files. I don't want a particular directory to be excluded, instead I want to exclude all files of type .class
when you open the File Search in Eclipse, there is a text box for filename patterns. You can enter the patterns you DO want to include, like *.java, *.xml, etc. (each pattern separated by a comma) , and it will only search in files of that type.
EDIT:
To exclude a file type, place an exclamation mark in front of the pattern, like
!*.class, !*.svn
I managed to exclude files of a specific extension in eclipse using resource filters:
Right-click on the project in project explorer -> select properties
Expand the Resource heading on the left of the properties window and select Resource filters
Select the Add Filter button
In my scenario, I was ignoring tar.gz archives:
So in this example *.class could have been inputted rather than *.tar.gz to ignore all files with the class extension.
You can create a Working Set pointing it to your java source dir,
and select it on Open Resource (Ctrl+Shift R normally)
Open Resource window Image
menu Image
The working set will be remembered when you open it again.

Searching a string in eclipse workspace

How to search for a string in the complete eclipse workspace?
I was not able to locate a text in the eclipse workspace however I could not find the specified string in the workspace.
At the top level menus, select 'Search' -> 'File Search' Then near the bottom (in the scope) there is a choice to select the entire workspace.
For your "File search has encountered a problem", you need to refresh the files in your workspace, in the Project/Package Explorer, right click and select "Refresh" at any level (project, folder, file). This will sync your workspace with the underlying file system and prevent the problem.
Press Ctrl + H, should bring up the search that will include options to search via project, directory, etc.
Ctrl + Alt + G can be used to find selected text across a workspace in eclipse.
Ctrl+ H, Select "File Search", indicate the "file name pattern", for example *.xml or *.java. And then select the scope "Workspace"
Eclipse does not search if the "File name patterns" field is empty.
So, if you want to search some text, write within "Containing text" field
and leave by default "File name patterns" with asterisk (*).
A lot of answers only explain how to do the search.
To view the results look for a search tab (normally docked at the bottom of the screen):
eclipse instasearch plugin is a very useful plugin for search needs inside eclipse.
It is based on lucene. This is also available in eclipse marketplace.
It has extensive feature set.
Instantly shows search results
Shows a preview using relevant lines
Periodically updates the index
Matches partial words (e.g. case in CamelCase)
Opens and highlights matches in files
Searches JAR source attachments
Supports filtering by extension/project/working set
For Mac:
Quick Text Search: Shift + Cmd + L
All other search (like File Search, Git Search, Java Search etc): Ctrl + H
Goto Search->File
You will get an window, you can give either simple search text or regx pattern. Once you enter your search keyword click Search and make sure that Scope is Workspace.
You may use this for Replace as well.
Press Ctrl+shift+L and type your string
In your Eclipse editor screen, try Control + Shift + R buttons.

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