Why so red? IntelliJ seems to think every declaration/method cannot be found/resolved

Solution 1:

IntelliJ sometimes gets confused all by itself, even without the external changes Korgen described (though that is a good way to consistently reproduce it).

Click File -> Synchronize, and IntelliJ should see that everything is okay again.

If that doesn't work, IntelliJ's caches might be corrupt (this used to happen a lot more often than it does now); in that case, regenerate them by

Clicking File -> Invalidate Caches and restarting the IDE

(though loading the project will take a while while the caches are recreated).

Solution 2:

I experienced this when I updated my JDK manually and removed the previous JDK

Red keywords

Solution

  • In the IntelliJ editor, click on the red keyword (Integer for example) and press ALT + ENTER (or click the light bulb icon)
  • select Setup JDK from the intentions menu

IntelliJ intentions menu

  • click on Configure

Project SDK selection dialog

  • In my case, the JDK path was incorrect (pointed on /opt/jdk1.7.0_51 instead of /opt/jdk1.7.0_65)

Broken Configure SDK dialog

  • Click on the ... and browse to the right JDK path

Fixed Configure SDK dialog

  • Let's clear the cache:

IntelliJ File menu

And everything should be back to life :)

No red keywords

Solution 3:

IntelliJ sometime gets confused after importing maven projects and then changing poms externally or generating sources outside IntelliJ.

You might want to try a maven->force reimport from within intellij on the project root