IntelliJ show errors in scala source files but the project compiles successfully - scala

I'm working with project in intellij IDEA IDE based in maven. I can perform all maven goals but IntelliJ is showing a lot of errors in the source code like bellow:
Everything worked fine a few hours ago. I don't understand why the IDE continue
showing errors. When I rebuild or compile the entire project (CTRL + F9) or a single
scala class I always receive a success message like that:
I already had configured scala plugin before, so I don't know what is happen.
thanks for your help

Sometimes the IntelliJ cache gets corrupted. You can fix this by the following:
File > "Invalidate Caches / Restart"
After choosing "Invalidate and Restart" when prompted, IntelliJ will restart and rebuild its cache.

If IDEA has lost track of obviously correct types such as Database or DateTime it probably means the configuration of the project is wrong or corrupted. Most commonly it does not have the required 3rd part dependencies such as Joda Time.
If you're not already doing so, define your project solely in SBT and use the sbt-idea plug-in to produce your IDEA project definition. Then whenever you change the project dependencies, re-run gen-idea to regenerate your IDEA project files. No muss, no fuss.

There are many bugs raised in jetbrains's bug tracker for this. I suggest you raise some bugs or vote for existing ones.
It loos like the problem you have is with the type aware highlighting which is worse than useless.

thanks for your responses.
I solved this problem importing the project again.

Related

IntelliJ show errors in scala source files but the (maven) project compiles successfully

When I open a maven module with scala code (link) which compiles and runs fine, I get bad error highlights:
Code-complete seems broken as well. How to fix this? (I don't want to switch to SBT since I only want this one module in the project to use scala, and I've tried the "Invalidate Caches / Restart" fix suggested here in vain.)
It is a known problem in IntelliJ with Scala because of the complex type system of scala.
I mostly use sbt. If I encounter such problem, first I compile it with sbt in the command line, most time wrong error highlights disappear.
If this does not help, clear IntelliJ cash and restart it (File -> Invalidated Caches / Restart).

Intellij resolving issues with scala

I am using Intellij Idea (v13/v14) for a scala project. IntelliJ is not resolving the classes and showing them in red colour. However, compilation works fine. Because of that, it is not possible to navigate to the other classes from a file.
Can anyone tell me how to fix this problem? It is making me crazy!!!
I would suggest to use IntelliJ 14 and get updated Scala plugin in first place. Then, open the project and invalidate cache.
https://www.jetbrains.com/idea/help/cleaning-system-cache.html
I guess either
The directory containing the source code is not marked as "source root" or
Intellij runtime memory size is small. Try increasing the values in idea.properties,

Stop exiting Eclipse with Play 2.3.X

If I run my application (Play 2.3.2) while Eclipse is running I always have strange compilation errors, no class def found errors, class not found errors, etc...
If I exit Eclipse and run my application, everything is working fine. But sometimes it's also working fine while Eclipse is running.
Am I the only one to experience that ? What is the cause ?
I suspect something in Eclipse changes my source files but I can't find what.
Maybe Lombok ?
Thanks.
I have similar problems. Typesafe responded with a solution which I am currently trying out.
https://groups.google.com/forum/#!topic/play-framework/4RnbqEk-muM
Brief summary of the answer by #jroper :
Eclipse doesn't know
how to keep its dirty hands off the same build directory that Play is
using to compile your app - if you have both Play, and the IDE, trying
to compile the same code at the same time, what do you think will
happen? You will see random errors. You should configure Eclipse not
to automatically build your app, or configure it to have different
output directories.
The Play Framework compiles everything to the directory target/scala-2.11/classes. When changing some of these classes, especially any views, causes Activator to auto compile the classes creating new class files. Hitting refresh on the project in Eclipse will update the project and class files in the classes directory causing a rebuild. This should make your compilation errors go away. If you still have issues, take a look at your .classpath file and the Eclipse build path settings.

Can anyone help me fix this m2e-jdt/jdt bug?

Introduction
I have spend a lot of time to fix this bug
In our application we have a lot of generated code by cxf and jaxb which produces tons of warnings. We use the maven-build-helper plugin to add this code to our projects automatically.
By adding this enhancement, eclipse JDT enabled the possibility to set the javac -nowarn flag for specific source folders. Unluckily, by updating the maven project the flag gets lost. There are a few threads on SO where users got bugged by bug.
What I have tried so far
So i came up with a clever solution, javac has a nowarn flag. I set it to my maven-compiler-plugin and specified the directory. My maven build was fine, but my eclipse build wasn't. My research told me, that eclipse jdt does only use the maven-compiler-plugin source and target version. So my next step was to try to configure the EclipseCompiler, but this is not possible, because there is no possibility to add custom compiler Arguments in eclipse JDT.
Next Step. Inside of the .classpath file, eclipse JDT adds an ignore_optional_problems attribute for each ignored path. By updating the maven project inside of eclipse, this entry gets lost. So i started to write a maven "ignore-source-folder" plugin which should add the missing attribute. To run the plugin each time eclipse starts a build, i also created a m2e connector to refresh the .classpath file and everything should be fine.
By testing my plugin with my connector i realized, it works, but only 70% of the repetitions.
What happened?
Every time eclipse m2e/Jdt starts a new build, all classpath entries will be removed and populated again. When my maven plugin gets triggered by eclipse, a race condition starts.
So I started to analyze the code of jdt and m2e jdt. The ignore_optional_problems flag gets only once set manually inside of the patch which was provided to JDT and isn't stored somewhere else. By triggering a new build via m2e-jdt this information gets lost.
How to fix this problem
To fix this problem, some element has to be added or extended in jdt which contains all ignored folders. If a new build gets triggered and the classpath file gets newly generated by m2e-jdt this element should be checked for ignored paths. ClasspathEntryDescriptor seems to be a good place for it.
My problem
I checked out jdt and m2e jdt, but i have tons of errors inside of my IDE and i have no idea how to start. And even if I fix the code, I have no idea how to build and test it. I think my effort will be to high and we talk about 20 or 30 simple lines of code.
I am afraid if I add my results to the filed bug at eclipse, no one will care about it.
So, is there any developer able and willing to help me for this tiny job?
You need to "fix" the M2E's JDT project configurator. Probably somewhere in the m2e-core project. So, your change should obtain some kind of configuration flag from the project pom and create corresponding classpath entries for JDT.

IntelliJ IDEA Scala plugin's syntax highlighting displays Scala packages in red

This is a bit weird, I've got IntelliJ IDEA 10, a fairly recent Scala plugin on it and sbt 0.7.7. I've been using the same setup on the same project for a while and syntax highlighting worked perfect.
After a few clean/compiles from sbt (I'm not really sure about the action), everything from Scala._ is red. For instance, List() is red but when I import scala.collection._ it gets fixed. The project compiles without any problems in both IDEA and SBT. What may be the problem?
(new/other projects are OK on the same setup so I guess I've messed up something but I have no clue where to look for it)
Thanks
I've never found a single solution to this, so i generally try all the things.
sbt gen-idea (to recreate IDEA project meta-data)
File > Invalidate Caches ... > Invalidate and Restart
After invalidating caches, upon restart IDEA will re-index all of your class files.
Usually I'll try
sbt> clean
sbt> gen-idea
Then if it didn't work go for invalidating caches. If that still doesn't work (and it almost always does) try deleting the following directories and then perform #1/#2 from above again:
target
project/target
.idea
.idea_modules
at project Settings, add the jars to its dependencies of IDE, then you will get the red away.
SBT is one thing, IDEA is another, they use their own way to compile scala. some sbt plugin for idea is also something that just hook sbt command line to idea's panel.
This sometimes happens to me when the SBT and IDEA projects get out of sync. Simply run the SBT Idea processor again - this regenerates your Idea project files.