Scala Eclipse IDE - strange behavior
Asked Answered
A

1

1

I am giving a try to Scala Eclipse IDE after a very long time. I installed Eclipse and the said Scala plugin only a while ago, but I am unable to get stuff working. In all of the Scala files, I get the errors like following (See the tooltip):

enter image description here

This project uses Gradle for building, and I also have the latest version of Groovy plugin installed. Please help me get this thing working. Thanks.

Edit:

Thank you, everyone. The problem was solved. It appears there was a problem with my Scala plugin installation. A complete reinstall of everything (including Eclipse) helped. Also, this time I did not install the Groovy plugin.

Amadeus answered 3/2, 2012 at 12:10 Comment(11)
The "J" in the icons for your files indicates that Eclipse treats them as Java files. It should be an "S" for Scala files. The errors would make sense for Java code. No idea how to fix it, though.Picco
May not make a difference, but given that you are using Groovy, why not use STS? I'm running STS latest with Scala IDE, zero problems, pretty awesome in fact, seemed to have arrived on the Scala scene at just the right time (as far as IDE support is concerned) ;-) Good luck!Council
Did you add the Scala nature to your project?Solar
How exactly did you import the project into Eclipse?Conducive
@themel, yes, I guessed that. Thanks.Amadeus
@virtualeyes, we are not using Groovy. Only Gradle. Thanks for the STS suggestion, will look into that.Amadeus
@PeterNiederwieser, File > New Project, and then pointed it to the project directory.Amadeus
It might be an issue related to the order of the nature / build command into the .project file. Try to put the "scala nature" / "build command" above the java ones. Then clean the project, cross fingers and hope it works.Toupee
@Nicolas, it's already in that order. :( Thanks anyway.Amadeus
So you are using the Gradle Eclipse plugin to generate the Eclipse project? The usual way to import such a project is with Import->General->Existing Projects into Workspace, although I don't know if it makes a difference.Conducive
@PeterNiederwieser, tried that. Didn't make any difference. Now trying out Matthew's suggestions. (Below in answers.)Amadeus
I
5

I don't know which version of Eclipse / Scala-IDE you're using, but there are two reasons I know this sometimes happens:

1) You don't have JDT weaving for Scala installed.

Installation details

The scala-ide uses aspects to weave in code into the JDT compiler. If you don't have this installed, this may cause the Scala files to be seen as Java files.

2) If, somehow, the Java Source File content type includes *.scala. In fact, it should be Scala Source File. If this is the case, you should remove the *.scala from the Java Source File content type.

Content Types

Innocency answered 3/2, 2012 at 14:40 Comment(8)
Thanks for the suggestions. (2) didn't work. For (1), how do I install JDT weaving for Scala? (Sorry, not well versed with Eclipse.)Amadeus
You can check to see if it's installed by Help->About Eclipse->Installation Details. If it's not, then get it from the update site, and it will be available from there (download.scala-ide.org/releases-29/stable/site). Do Help->Install New Software, and choose the update site.Innocency
By the way, there used to be known incompatibilities between the Eclipse Groovy and Scala plugins. Not sure what the current state of this is, but if you aren't using Groovy and don't use the STS Gradle plugin, there is no reason to have the Groovy plugin installed. (Not even sure if the Groovy plugin is currently needed to use the STS Gradle plugin.)Conducive
@MatthewFarwell, installed JDT, restarted Eclipse, refreshed project etc. No difference.Amadeus
@PeterNiederwieser, would you suggest uninstalling Groovy plugin?Amadeus
I'd recommend to uninstall all Eclipse plugins that you don't need. :-) Seriously, I'd certainly give it a try.Conducive
Thanks everyone. It appears here was a problem with my Scala plugin setup. A complete reinstall helped (of Eclipse, too). Also, this time I did not install the Groovy plugin.Amadeus
@Amadeus In theory, there should be no problem installing the Groovy and the Scala IDE plugin togheter, as long as you use the Scala IDE 2.0.0 release (or later). In fact, before the final 2.0.0 release there was indeed an issue (scala-ide-portfolio.assembla.com/spaces/scala-ide/tickets/…), but it should work fine now.Forgiven

© 2022 - 2024 — McMap. All rights reserved.