Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala: IntelliJ highlights correct code in red

One fine day IntelliJ started highlighting my working Scala code in red. While following commands run without a hitch, IntelliJ thinks that code is full of errors an missing a lot of dependencies.

  • sbt clean
  • sbt reload
  • sbt update
  • sbt compile
  • sbt assembly

It reports a lot of Cannot resolve symbols in imports, classes and method-calls on objects like the following. Moreover, it thinks a lot of imports are unused (for the symbols that it can't find) enter image description here

Interestingly, all this is happening in only one of my projects (that contains two submodules inside parent module), while other Scala projects (including those containing submodules) are working fine.

Things that I've tried without luck:

  • Delete (rm -rf) build-related directories like .idea, target, ~/.ivy2/caches
  • Invalidate Caches / Restart...
  • Update IntelliJ IDEA and Scala plugin to latest versions
  • Close and re-import the project, quit IntelliJ, reboot the PC (!)

I'm using:

  • IntelliJ IDEA 2017.3.2 (Community Edition)
  • Build #IC-173.4127.27, built on December 25, 2017
  • JRE: 1.8.0_152-release-1024-b8 x86_64
  • JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  • Mac OS X 10.13.2

My project configurations are:

  • Scala v2.11.11
  • SBT v1.0.3

Once again, I'd like to remind that my Scala code is completely functional and that I'm able to run the JAR generated by sbt assembly elsewhere without an issue.

like image 411
y2k-shubham Avatar asked Jan 15 '18 12:01

y2k-shubham


People also ask

Why are my files red in IntelliJ?

It means that the files exist locally, but are not in the repository, and are not scheduled for addition. With other words, the files are not under version control. There is not really a problem since the files can just be added to the VCS if desired.

What does red filename mean in IntelliJ?

If you are referring to the file name being in red, that indicates there was a Version Control System (VCS) merge conflict (or the file was changed as part of two different change lists and has not yet been acknowledged).

What does green highlight mean in IntelliJ?

Green highlighting means Language Injection (HTML flavor in your case). In such fragments you will have inspections/code completion specific to the injected language. Automatic injection rules can be configured at "Settings | Language Injections".


1 Answers

This solution worked for me: Why does intellij IDEA highlight build.sbt?

Go to the menu: File > Invalidate Caches/Restart

like image 155
vejeta Avatar answered Sep 20 '22 08:09

vejeta