167

IntelliJ IDEA 10.5.1 is reporting zero usages for all method, classes etc.

Can I force IntelliJ to rebuild the project indexes?

xIsra
  • 867
  • 10
  • 21
Paul McKenzie
  • 19,646
  • 25
  • 76
  • 120

2 Answers2

325

File -> Invalidate caches...

(Force rebuild of all caches and indices on next startup)

Restart IntelliJ IDEA.

Caution: This might Remove local history.

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
  • 7
    how do you get intelliJ to only index certain folders? – FutuToad Jan 24 '14 at 17:51
  • 3
    it was not my problem but +1 for the tip – MoienGK Aug 06 '14 at 06:36
  • 2
    This cleared up a compilation problem I was having in IJ 14.0.3 where IJ was not resolving imports from dependent modules even though they were explicitly included in the project structure. You no longer have to restart IJ. – wjohnson Feb 24 '15 at 07:48
  • This fixed an issue where Android `Activity` subclasses were not being recognised as being a `Context` subclass. Pity it also clears local history though – Xiao Dec 23 '15 at 00:47
  • I had a problem where indexing seemed corrupt and kept running. The solution above fixed it. Thank You – Maged Makled Apr 27 '16 at 16:22
  • 5
    Caution: File -> Invalidate caches will remove local history – user3366706 Jun 12 '18 at 21:59
  • 1
    I just used this IJ 2019.3.3 worked like a charm! I checked my local history and it's all there... @user3366706 It "might" remove local history. for me, it did not. – Moshe Slavin Aug 26 '20 at 14:06
  • 3
    It works, but I expect better for JetBrains; it's ridiculous that I have to restart just to fix bogus Red Flagging in source files, caused by puzzling stale parser state, hmm. It would be far better if I could select a file or tree and tell it to re-parse the files. – Infernoz Sep 19 '20 at 23:45
  • Submit the idea on their website @Infernoz – Boris Pavlović Sep 20 '20 at 07:05
2

Restarting IntelliJ fixed this in my case (Ultimate 2019.1) -- on restarting, it rebuild the indexes by itself.

An interesting side effect, apart from all imports and non-local references coming up as errors, was the error reported on all string literals:

Incompatible types. 
Required: java.lang.String 
Found: java.lang.String
drevicko
  • 14,382
  • 15
  • 75
  • 97