I'm having a problem in which I can build a Scala project enough to run or debug a class, but Scala code in an editor window is full of red underline error markers.
The claimed errors seem to indicate that the Java presentation compiler is being run on the Scala file. For example, the first claimed error is that a semicolon is expected after "package a.b.c"--as if it's looking for a Java package declaration (e.g., "package a.b.c;").
I suspect that something is wrong in the Maven setup for the project (probably that somehow it's referring to the source folder for Scala files in a way that makes Eclipse think that they are Java files). However, I'm not familiar enough with Maven, doing Scala in Maven, or Scala-IDE to know how things should be set up or exactly what to look for.
Does anyone have any recommendations on how to set up Scala and Scala-and-Java projects in Maven so that they work with Eclipse (and IntelliJ IDEA)?
Specifically, what's necessary in Maven for telling Eclipse that src/main/scala is a Scala source folder?
In the Maven projects I'm working on, some of the POM files have <sourceDirectory.../> elements for Scala source subtrees, but I don't know if that's is needed for Eclipse (and the Scala Maven plug-in causes it to be treated as Scala subtree) or if that would cause the Java part of Eclispe to think that it is a Java subtree).
Some details on the symptoms that might help:
With automatic building turned off, when I clean all projects, things work as expected: I get expected Scala errors: A handful of references to classes/traits declared in a depended-on project get red-underlined in the Scala source.
When I rebuild the project, things work as expected: Eclipse builds depended-on projects, and the red underlines on those handful of references to go away.
Running or debugging after rebuilding works as expected.
However, if I edit the Scala source file (even just adding whitespace), save it, and then try to run again, the source file becomes marked with tons of red underlines, and the runner says that the project has errors, and asks if I still want to run. When I say "yes," the runner tries and then says it can't find the main class.
However, if I try to run again (without rebuilding), although the runner again says that the project has errors, if I proceed, then the class runs (and the editor still shows tons of errors).
Because the class actually runs, it seems clear that the real (non-presentation) Scala compiler is being run on the class (under some triggering conditions).
Because cleaning causes the expected handful of references to show up as errors, it seems clear that the Scala presentation compiler is being run, at least by the clean command.
Because editing the file and trying to run it causes tons of errors to show up and they seem like Java-compiler errors, it seems clear that the Java presentation compiler is also being run on the Scala file (under certain triggering conditions).
What would cause part of Eclipse to treat the file as a Java file while the rest treats it as a Scala file?
Thanks,
Daniel