Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Scala application in Scala IDE with compilation errors

Is there a way to run a Scala application or unit test within the Scala IDE 2.0.2 (Eclipse 3.7) if there are (unrelated!) compilation errors in the project?

In Java, this is no problem, but Scala IDE keeps telling me:

Project contains compilation errors (therefore, no binaries have been produced).

All I want to do is to run a small test during a major refactoring process, but I can't fix all compilation errors right now. And I don't want to start commenting things out, as those compilation errors are good reminders of tasks that still need to be done.

like image 373
rolve Avatar asked Nov 01 '12 14:11

rolve


People also ask

How do I run Scala IDE?

Once you have installed and generated the Eclipse project files using one of the above plug-ins, start Eclipse. Use File → Import → General/Existing Project into Workspace. Select the directory containing your project as root directory, select the project and hit Finish. And Voila.

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.

Can Eclipse be used for Scala?

Scala IDE. The Scala IDE for Eclipse is centered around seamless integration with the Eclipse Java tools, providing many of the features Eclipse users have come to expect including, Support for mixed ...


2 Answers

Currently the Scala IDE does not support this behavior, but it would be nice if it could.

To be aware of this, I created a ticket:

JDT allows to execute Java code despite of compilation problems in the sources. Internally JDT replaces the defective code with an exception, which is thrown if the relevant code is executed. But if the defective code is never called during execution, nothing bad happens. It would be nice if SDT supports similar behavior.

like image 199
kiritsuku Avatar answered Sep 28 '22 18:09

kiritsuku


If you are using Scala 2.10, a good option is to use the newly introduced ??? notation. This way your code will compile even if the function is not yet implemented.

There is certainly a better way but this one will still be better than commenting code.

As suggested by Jesper, you can still implement ??? if you are working with previous versions of Scala:

def ??? : Nothing = throw new Error("Not implemented") 
like image 33
Christopher Chiche Avatar answered Sep 28 '22 17:09

Christopher Chiche