Change default scope of "Find Usages" in IntelliJ - intellij-idea

When I run "Find Usages" in the latest version of IntelliJ (2021.2.3 Ultimate Edition) it uses the scope "Project and Libraries" by default whereas I usually want to limit the scope to "Project". Therefore my current workflow is
right-click on the thing of interest (class, method, etc.) and select "Find Usages" from the menu
in the results panel click on the settings icon (gear wheel)
in the dialog that appears (see below) change the scope to "Project"
click "Find" to re-run with the correct scope
Every time I run "Find Usages" I have to go through the steps above, because it always defaults back to using the "Project and Libraries" scope. Is there some way I can change it to use the "Project" scope by default instead?

Related

Can I use the module structure (collapse Java package paths) for the Project Pane -> Changed Files view in IntelliJ?

When I use the "Project Pane -> Project" view in IntelliJ, my Java package paths are collapsed based on the Modules in my Project Structure (e.g. com.company.project). I would like to use IntelliJ for code reviews, so I've checked out the changes locally and am looking at the "Project Pane -> Changed Files" view, but this doesn't pick up the project structure, so each folder takes an extra line. Can I get the best of both worlds here?
I figured this out with the help of this answer about expanding the folders (which I also wanted to do) How to expand folded package chain in Intellij IDEA?
Right click on "1:Project" to see the options for the project pane and then check "Flatten Packages".

Exclude files when using "Find Usages" in IntelliJ IDEA

In Java source files, when I select a class or a method, then click the right button of mouse, in the pop up context menu, and run Find Usages, the files that use the class or methods are searched out.
But I would like to exclude certain files (e.g. JUnit test files) from the search results.
Where could I configure this?
From the docs; you can confgure the Find Usages scope by clicking on the tools icon in the top left hand corner of the Find Usages results.
Here are some screenshots:
Click on the tools icon here:
Click on the build button (... next to the Scope field) to create a Scope and define it like so (in this examples I have included production classes and excluded test classes):
Choose that scope in the Find Usages dialog:
Notes:
You can also chose the precanned scope named Project Production Files from the Scope dropdown
All subsequent searches will use this scope by default until you choose a different scope.

IntelliJ "Looking for Usages" freezes when refactoring/renaming enum entry

I am using IntelliJ IDEA Community Edition 16 Preview (version IC-144.4199.23). I need to rename a couple Enum entries using IDEA's Refactoring system.
For instance, I currently have an enum entry named black, and I need to rename it and its usages to BLACK, which I do by Right-clicking the entry, selecting Refactor -> Rename..., and entering BLACK.
The problem is that IDEA prompts me with the Looking for Usages progress dialog, freezes the dialog, and never actually refactors the entry name.
This issue is pretty odd, because when I use Find Usages on the entry directly, it perfectly says that there is "No usages found in Project Files" (which is normal). However, the aforementioned dialog freezes at a roughly 99% progress bar in searching for occurrences, and does not proceed in renaming the entry.
Edit: Issue also applies to IntelliJ IDEA 15.0.2, apparently.
When you click the type of refactoring, make sure that in the 'Choose scope where change signature may occur:' you DO NOT choose "All Files", but rather something else - such as "Project Files". Otherwise, it's going to take forever!

IntelliJ IDEA Puts Checkout Files in Changelist Other Than Default for Perforce

My IDEA is linked to perforce. When I check out files for editing in IDEA, it automatically puts the checked out files into a changelist other than the default one. How can I change the settings so that the checked out files are to be put in default changelist?
It turned out that I needed to change the "Active Changelist" in Idea. Here are the steps:
In Idea, open “Change Tool Window” by clicking on Menu “View” -> “Tool Windows” -> “Changes"
Right click on the “Default” changelist(or any changelist you want to set to active/default) in the Tool Windows and click “Set Active"

Adding an entry in a submenu of a popup

I'm building a plugin, and adding an entry to the context menu (right-click on a folder in the project tree).
So far it works, following this tutorial:
http://www.eclipse.org/articles/article.php?file=Article-JFaceWizards/index.html
The problem is that it's adding my entry in the root of the context menu. Since my entry refers to a "New XXX" wizard, I want it to go to the "New" submenu.
It seems like I would have to set the correct locationURI or menuPath in my plugin.xml. However I can't find the locationURI or menuPath corresponding to that submenu. How can I find that?
The new contributions are menu ID based, not menu path based. So it should be something like:
<menuContribution
locationURI="menu:file?after=additions" />
See this SO answer for an example of locationUri.
See Menu Extension for more. The exact id is either:
found in the existing plugin.xml from the menu or
determined with plugin Spy
See "How to add items in popup menu?" (from justinmreina) for more on adding an entry to a menu.
If you've created a plugin for a 'New XXX' wizard, you can add it inside the 'New' menu that you see when you right-click inside the Navigator by customizing the perspective.
Go to Window -> Customize Perspective and click on the Shortcuts tab. You should see 'New XXX'. Select it and you're good to go.