Add an option to context menu in vscode (only to workspace folders) - visual-studio-code

I read the vscode API documentation here https://code.visualstudio.com/api/references/contribution-points#contributes.menus and found that I can identify the folder in the "when" clause, but I am not able to find any API which allows me to identify if this is a folder present in the workspace.
To identify if it's a folder, I use "explorerResourceIsFolder" context name from https://code.visualstudio.com/docs/getstarted/keybindings.
I would like to know a way in which I can identify that the folder is a workspace folder and then I will be able to add an option to the context menu.
Example: In this link https://code.visualstudio.com/docs/editor/multi-root-workspaces, I want to add an option to the context menu when you click on the folder "vscode", "vscode-docs", etc.

I found out that there is a when clause "explorerResourceIsRoot" which can be used for this scenario. This is definitely not in the documentation as the list is not exhaustive as mentioned in the documentation.
I found it from the keybindings(there are when clauses mentioned for various commands) in vscode which you can navigate using the information here https://code.visualstudio.com/docs/getstarted/keybindings#_default-keyboard-shortcuts or simply do CTRL+SHIFT+P, search for keyboard shortcuts.

Related

How to make Eclipse ignore some files during lookup?

In Eclipse, there is the option to lookup a specific file by going to Navigate > Open Resource. Once the popup open, you can type to search for a file in the project. Is there any way to make this lookup ignore some files and not show them?
This is only possible to do by "inclusion" (that is, telling Eclipse which files to include during the search), not by "exclusion" (telling Eclipse which files to exclude).
In the "Open Resource" dialog, notice that there's a small down-pointing arrow at the top right. From there, you can select the Working Set which will be considered during the search. You can define the working set as the collection of resources to consider during search; only resources that are contained within the working set will be shown.

Search in particular Eclipse project

Is there any way to specify a project, where you want to search?
It's been annoying me for a long time. Like when I hit Ctrl+H to search, the only scopes available are:
Workspace
Selected resources
Enclosing projects
Working set
So, the only 3 ways I see to perform a search in particular projects are:
Open a file from the required project, hit Ctrl+H and choose Enclosing projects scope
Add required project to Working set, and perform search on this set.
Select a project in Project Explorer and search in Selected resources
All of these methods are not always convenient.
Sometimes, I just want to manually specify projects, where the search is to be performed
Edit:
The last option is not good for 2 reasons:
1) I usually have "Link with editor" option on, which associates currently opened file with corresponding item in Project Explorer. Our project is quite large, so usually I would have to scroll all the way up to collapse the selected project to make others visible.
2) Also, Project Explorer is not reachable when I'm working in another perspective, such as Debug for example (I know I can add it through Window->Show View, but that just breaks the essence of perspectives).

How do I Ignore the build folder in NetBeans 'Find In Projects'?

Anyone know how to ignore the build folder when doing a 'Find in Projects' on NetBeans (v6.9.1).
Currently the Search results pane shows all results from src folders but also those from the build folder so if your project contains a lot of JSP files for example, many results are duplicated...
I think I've figured out how to ignore the build folder of projects when doing a 'Find in Projects' in NetBeans 6.9.1:
Go to Tools->Options-Miscellaneous.
Click the Files tab.
In Files Ignored by the IDE, edit the Ignored Files Pattern
regular expression and include the build folder. For example, on
my system I simply added build thus:
^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn|build)$|~$|^\.(?!htaccess$).*$
Click OK to save the options and close the dialog.
(Nerd Note: Took me exactly 1 year to the day to figure this out!)
You may be able to get similar behavior with a multiple node selection search.
From the 'Files' Window (Found in the Window/Files Menu), expand all
of your projects and select all of them with a Ctrl+A (PC) or
Command+A (Mac).
Then with Control(PC) or Command(Mac) key held down, click the
folders that you don't want to search.
Finally, use Ctrl+F(PC) or Command+F(Mac) to open a search, enter the
text you're looking for, and then choose 'Selection ( # nodes)' under
the Scope where the '#' symbol is the number of folders you just selected.
It is a little more manual than applying a filter, but you should be able to better control your results.

Is it possible to specify in Eclipse managed projects the path of a library independent of configuration

Within Properties/Settings/Tool Settings, one can specify a Library search path (-L).
For a specific build configuration one can enter
${workspace_loc:/SomeLib/Debug} or ${workspace_loc:/SomeLib/Release}
depending on the configuration.
Is there a variable, like ${workspace_loc} that can be used specify a 'universal' search path. This path would then be correct regardless of the configuration.
Such as:
${workspace_loc:/SomeLib/${config}}
BTW, Is the Eclipse documentation showing a list of all the workspace/project variables?
One thing you can do is create you own string substitution. "You can create and configure simple launch variables which you can reference in launch configurations that support variables".This is done under "Preferences">"Run/Debug">"String Substitution".
As far as list of possible variables goes, I found that if you go to "Run Configurations" and select "Arguments" tab then click on "Variables..." button - you'll get a window with all variables and their descriptions. You can even edit string substitutions from there.
Hope it helped.

searching in eclipse

how can I search something in all files in a given folder in eclipse
also how can I search up, it's seems like only going down the document
sometimes I am working on single files, so there is no project defined. I know about the search in project feature
If you go to Search>Files... you'll have an advanced search dialogue where you amongst others can specify the scope to search in (all of the workspace, selected resources only etc.). Is this what you're looking for?
And also, if searching through a single file (+), you have the standard search dialogue where you can specify search direction to either forward or backward.
Search forward in file: Edit -> Incremental Find Next
Search backward in file: Edit -> Incremental Find Previous
Search in multiple files: Search -> File -> Containing Text.
Search files in a specific subdirectory: Select the sub-directory -> Search -> File -> Scope: Selected resources.
I reccomend that you learn the short-cuts for these tasks. (Key-combination is found right beside the menu-item.)
When you are searching "Java Resources" with "File Search" with "Selected resources" checkbox checked - you will not get any results.
To search recursively a chosen folder for any files:
Select folder (it has to be folder)
Select FileSearch with "Selected resources" checked.
Good luck
Use the Remote Search Feature. Here you can browse for local folders. Some stupid name...
If default eclipse search is not sufficient for your needs, 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
If you want to search for anything without telling Eclipse what it is, use ctrl+shift+L (QuickEclipseSearch). This is the quickest way.
You can also use 'file search' (press ctrl+H) and navigate into file search using left and right arrrows on the top right corner of your windows. Or type 'file search' in the 'Quick Access' window.
If you are looking for a specific method, package, field,type or constructor use JAVA search.
If you want search in a particular file then just press ctr+F and type whatever you want to search in that current file.
Read all the answers above but couldn't figure out the solution working for me. Finally gave a thought process keeping in mind all the solutions provided here and voila it worked for what I'm looking here. Thanks stackoverflow, this site is awesome.
Solution I worked out:
Goto Navigator window in eclipse, select the folder where you want to perform the search operation, now click Alt a & f (shortcut) which opens the file search window. Now select the option "Selected resources" in 'scope' section and hit 'Search' button.
In MAC I use, control+H (^H), it opens a window, where you can search for any text within all the files.