Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse not recognizing Scala code

I have Eclipse Indigo with the Scala IDE plugin. I downloaded a lift project from Maven. It builds correctly. Eclipse says it is viewing it with the Scala editor.

However, it is still giving my an error on each line because it is treat the code as Java (it gives errors for no semicolon, for the word "def" etc.) I tried cleaning the project and it still gives the errors.

like image 687
Joe Avatar asked Dec 15 '11 15:12

Joe


People also ask

Can we write Scala code in Eclipse?

Using the Eclipse IDE, we will create a simple Hello World program in Scala. Open the Eclipse, click on the menu and click on the “New” ->Scala project.

How do I import a Scala project into Eclipse?

To import the Scala IDE in your workspace simply click on File > Import. The Eclipse Import dialog will open. There, select General > Existing Projects into Workspace and click Next. A new dialog will open.

Which Eclipse IDE is best for Scala?

Intellij is by far the best I have used. IntelliJ works well. However, it does choke on some of the functional libraries like cats (false highlighting). …it works in scalac, and in Eclipse/Scala-IDE.


2 Answers

A couple of things I would try:

1) Right-click on project, Configure > Add Scala Nature.

2) In the Scala menu, Run Setup Diagnositics... > Use recommended default settings

like image 179
Luigi Plinge Avatar answered Sep 21 '22 20:09

Luigi Plinge


Open the Package Explorer, look at your scala source. Does the icon displays a S (for Scala), or a J (for Java)?

If you see a S, then you are likely missing the Scala Nature. As Luigi suggested, try to add the Scala Nature and see if that fixes your issue (Right-click on project, Configure > Add Scala Nature.)

Otherwise, if you see a J, the odds are that "JDT Weaving" is not enabled. That should not happen and might depend on other plugins you have installed.

What I would try if I were you is simply uninstalling all Scala IDE plugins from Eclipse ("Scala IDE for Eclipse", and also the "JDT Weaving for Scala" if you see it in the list of installed plugins). Then, reinstall Scala IDE 2.0.0-RC04. I know, it's not the ideal solution, but it's hard to tell what is going on without more information.

If that doesn't work either, please write a message in the scala-ide-user Mailing List. Make sure to provide the full list of plugins you have in your Eclipse installation. That might help us understand what is going on.

like image 37
Mirco Dotta Avatar answered Sep 25 '22 20:09

Mirco Dotta