intellij find usages behaving strangely - intellij-idea

Is there a way to search a project for all uses of some text, without highlighting that text first. I.e. bring up a search interface, and then type in the text I want to find? I'm not seeing how to do this in the Intellij docs.
Note, when I select some text in a file and I do a Search->Find Usages, it responds by giving a little popup "Cannot find usages. Position to an element which usages you wish to find and try again". I get this whether I search on a variable name in a groovy file, or some text in a comment. So for some strange reason, this isn't working at all.
I'm using Intellij Ultimate 10.5 (version 10.5.1)
Thanks for any help or workarounds.

Is Search->Find in Path what you're looking for? (Ctrl-Shift-F on Windows) You can find text in the whole project, a certain directory, or a custom scope.

I was having the exact same problem searching strings in strings.xml but the project wasn't compiled against that file.
So make sure you have compiled against that build variant, module, flavour, etc.

make sure project configuration is allright
File -> Project Structure -> Project -> set correct SDK
File -> Project Structure -> Projects Settings -> Modules -> + -> Import Module -> import your gradle or maven projects
now clear all existing cache
File -> Invalidate Caches
restart Intellij and wait until the indexes are rebuild. Worked for me :)

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".

Intellij exclude file from being compiled

I am trying to exclude a particular file in my project from being compiled.
According to the Intellij IDEA documentation you do this by "marking the file as plain text".
However, the context menu in the project view where this functionality is supposedly located has no such action. I am using version 13.02 of Intellij. Here is what my context menu looks like:
Under File > Settings > Build, Execution, Deployment > Compiler > Excludes, add an entry.
Any attempts to run a path specified here will result in a ClassNotFoundException, and a very important class indicator as well.
Just to compound on Makoto's answer (would comment but don't have reputation), it looks like this feature does not apply to classes (.java) or assets (images)...for these types of files, it looks like you will need to actually go to the compiler and explicitly state that the file(s) should be excluded.
However, for .htm, .xml, or really anything that isn't a class or asset you will find and can use the 'Mark as plain text' option.
Edit: It looks like you can also go to the 'Messages Make' error / warnings view and Exclude from there, a little less work IMHO.
The answer that #Makoto has given is pretty much the way to go, but in case that you are like me and you get easily both distracted and frustrated looking for that menu, you could use this shortcut:
press ctrl + shift + a , and in the input box that appears type excludes, and select the first item that appears.

Refactor rename broken in Intellij IDEA

Somehow, I managed to break my refactoring capabilities in Intellij IDEA 12. I have somehow disabled it for my project. Renaming a member through Shift+F6 doesn't work. The inline edit box is not drawn, nothing happens.
I know of the refactoring settings in Settings -> Editor, Enable in-place mode and Preselect old name are both checked.
It has to be some kind of project setting. I checked by creating a test project, adding some member and renaming it, which works perfectly.
What setting am I looking for? Or could my project be broken?
There is no way to turn refactoring off in the settings. My guess is that the project's cache/indexes are corrupted. I had a case once where refactoring, especially renames, stopped working. A re-index solved it for me. Go to File >Invalidate Caches, invalidate your caches, restart IDEA, and let IDEA re-index the project (progress is shown in the bottom status bar right of center). Then try the refactoring.
If that does not solve it, take a look in the logs (Help > Show Log) and see if there is any indication in there as to the cause of the issue.
Fo all the MacOS users, do not forget to access Settings -> Keyboard and turn on the flag for the option Use all F1, F2, etc. keys as standard function keys. E.g.:
Otherwise IntelliJ will not get the focus to use the F4 key.
Following step worked for me:
From your IDE, go to: Preferences -> Project Structure -> Add Content Root, then select the folder you want to use.
None of the above steps worked for me in IDEA 2021.2.4 (Ultimate Edition). I got the following error message when trying to rename a file and its usages:
Cannot perform refactoring. Selected file is not located inside the project.
Instead, I had to create a new module.
File > Project Structure > Modules > Add (+) > Import module > Select <root_folder_of_your_project>
This reindexed the whole project, which took a couple of minutes, and restored the Refactor > Rename functionality.
waite for some time it can be due to running Indexing

IntelliJ missing all inspections

I'm having an issue with IntelliJ, that I cannot seem to find a solution for myself. I have not changed any settings, yet when I started my IDE this morning, all Inspections and other highlighting has disappeared.
By highlighting, I mean stuff like variable names becoming purple, static finals shown with italic text, etc.
Inheritance seems to be broken as well, in that an implementing method links to the implemented interface method, but interface methods do not link to the implementing method.
My search for this tells me that there is an icon for this in the bottom right. That's set to "Inspections", and under configuration, it seems like everything is set to default.
Is there some way to un-break my IDE?
Another solution:
File -> Power Save mode
It needs to be disabled.
The (or at least one) answer to this is:
File -> Invalidate Caches
Make sure the folder the code is in is marked as the sources root. If it's not marked as the sources root, syntax highlighting will be very limited.
To mark a directory as the sources root, right click the directory, then navigate down to "Mark directory as" and select "Sources root."

IntelliJ 12, module-depenencies all red, no path.

I have a real problem with making Play2.0 work with IntelliJ EAP version (120.152).
I create an empty project without module in IntelliJ
I create a new application using the play command, and using play idea at the end
I then add this module from IntelliJ, using "Import from existing module"
Now, I have two folders too chose from when importing the module.
1. .idea
2. .idea_modules
After seeing some different ways on the internet,
I chose .idea_modules -> moduleName.iml
(I have tried all the others just to check)
Here is what bothers me the most
Anyone had anything similar? I am not sure why this is, every other screenshot I have seen from this, have a path behind the red text (making it work!), which I do not.
Any suggestions what I can do from here to hopefully make this work?
My Scala facet looks like this in the IDE, but I have not seen any Play documentation that goes into modifying the facet, so I just leaved it as is
In IntelliJ 12 - the same as in IntelliJ 11 you can open the Play's project since version 2.0.2, just by using option 'Open project' in the start window view.
You don't need to create blank project first in IDE.
play new test-leda + all required steps by play console
cd test-leda
play idea + wait for bash prompt which indicates finalization
Open Leda and choose Open project
Find the folder test-leda and just click Choose
That's all