'IntelliJ Ultimate 14 find usages not working
I am using Intellij IDEA 14 Ultimate. When I search find usages, in find view there is a info like
Searching for usages in project files" and doesn't return any result. Scope is "whole project".
I have also IntelliJ 14 Community Edition. When it try find usages in community edition, it works.
Do you have any idea?
Solution 1:[1]
I had exactly the same problem, so for people looking for the quick answer, try
File -> Invalidate Caches / Restart
Thanks to user @yole and his comment.
Solution 2:[2]
If it doesn't solve by File -> Invalidate Caches / Restart
then make sure your 'src' folder is marked as 'Sources' in project structure.
Solution 3:[3]
If File -> Invalidate Caches / Restart is not working -> close the project, remove it from recent projects and then delete the .idea folder then open the project again.
Solution 4:[4]
There are also other cases the "Find Usages" feature does not work. I can illustrate one very simple case.
Provider.java:
public class Provider {
private static final Provider instance = new Provider();
public static Provider getInstance() { return instance; }
public Integer getID() { return 0; }
}
User.java:
public class User {
private final Integer pID;
public User() { pID = Provider.getInstance().getID(); }
}
If you click on the getID() method in Provider.java and call "Find Usages" it finds the call in the User.java easily. But if you rename or remove the getInstance() method in Provider.java then it won't find the getID() call in User.java anymore.
I assume that it happens because the line Provider.getInstance().getID() is marked with red (compilation error) and the "Find Usages" feature does not consider this failing code as a valid call of getID(). It means that, at least some compilation errors affect the "Find Usages" results.
I was curious enough to look into the list of bugs related to this feature on https://youtrack.jetbrains.com/issues?q=find%20usages and there I saw there are other cases and made my conclusion. To sum up, if you don't like to keep in mind all the conditions in which it works and want always full search I recommend using grep which finds always and everything.
Solution 5:[5]
In PhpStorm version 2019.1 on a Windows machine, if you hold AltGr key and hover on a function, it appears the popup 'Show usage of Method ...' but it's misleading since doesn't find the calls to that method from other files.
The correct way to show usages, is to hold the Ctrl button and click on the method name.
Solution 6:[6]
Sometimes problem in your code format structure.
Try this - Press ctrl+alt+shift+l and
Choose selected text
Code cleanup
then your problem is resolved
Solution 7:[7]
You can also temporarily force a "bad" source folder (ex: .../tmp), then switch back to the correct source folder (ex: src/main/java). This, combined with cache cleaning as explained in the other posts solved the problem for one of my collegues.
You declare / undeclar source folder with a right click on the folder, then "Mark Directory as ...".
Solution 8:[8]
have u tried mark directory as -> Project Source and Header?I just work out it in CLion.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eel Lee |
| Solution 2 | Abhijeet Jadhav |
| Solution 3 | Mohankumar M |
| Solution 4 | Alexander Samoylov |
| Solution 5 | T30 |
| Solution 6 | mnestorov |
| Solution 7 | toggeli |
| Solution 8 | HuSharp |
