61

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?

Andrew Tobilko
  • 46,063
  • 13
  • 87
  • 137
karlkeller
  • 1,191
  • 3
  • 11
  • 22

8 Answers8

88

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.

Eel Lee
  • 3,434
  • 2
  • 30
  • 45
  • 2
    Worked for Intellij 16 – jbarrameda Sep 27 '16 at 15:26
  • 1
    Worked for Idea 13.0 in ubuntu – shakhawat Nov 27 '16 at 05:08
  • 2
    Worked for PHPStorm 2017.1 on MacOS Sierra – seven77 May 15 '17 at 23:17
  • Worked for IntelliJ 2017.2.1 – Brian Aug 15 '17 at 15:23
  • 1
    should be called "Invalid Caches & Delete Your Local History" if there was one feature I really wish IDEA would implement it would be to separate the two, I actually like my Local History - plus most times people suggest Invalidating Caches, it doesn't actually help so I lose my Local History for no reason - in this case it actually did help (I think I corrupted things by quitting IDEA after upgrade before it finished indexing) – ycomp Dec 05 '17 at 05:18
  • This solution is still working for IntelliJ Ultimate 2017.3 – Mathieu Castets Dec 05 '17 at 10:26
  • I'm not sure whether I should be more surprised that this works, or that this is necessary. Eclipse seems to be smart enough to find references reliably without making users "invalidate and restart", why can't Android Studio do it? – Krease May 01 '18 at 23:50
  • Worked for Pycharm! – Atul Mishra Apr 15 '21 at 08:32
  • Fixed the issue for PyCharm 2021.1. Have never seen that issue before, after working with PyCharm and IntelliJ for years. But invalidating cache fixes it. – Ursin Brunner Apr 18 '21 at 14:42
17

If it doesn't solve by File -> Invalidate Caches / Restart then make sure your 'src' folder is marked as 'Sources' in project structure.

Abhijeet Jadhav
  • 252
  • 3
  • 8
  • wow, If i open a project with "Open" i certainly would expect that that folder would be automatically searched. This worked for me. – darKoram Jun 11 '18 at 16:24
2

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.

  • In my case mine was a gradle project and in addition to your steps I deleted the .gradle folder as well and then it worked. – rumman0786 Dec 10 '21 at 07:09
1

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.

Alexander Samoylov
  • 1,868
  • 1
  • 19
  • 26
1

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.

T30
  • 10,276
  • 6
  • 47
  • 57
0

Sometimes problem in your code format structure.

Try this - Press ctrl+alt+shift+l and

  1. Choose selected text

  2. Code cleanup

then your problem is resolved

mnestorov
  • 3,508
  • 2
  • 14
  • 22
0

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

toggeli
  • 17
  • 3
0

have u tried mark directory as -> Project Source and Header?I just work out it in CLion.

HuSharp
  • 119
  • 1
  • 3