I am unable to get a scala worksheet to find any of my project classes when using Intellij. I have added the new scala worksheet to the src
directory of my project as instructed here. However whenever I try to run the worksheet I get the following error
Error:(5, 27) not found: type Order trait LimitOrder extends Order { ^
The Order
trait is defined in a file included in src/main/scala
. I even tried putting the scala worksheet in the src/main/scala
and it still fails to find the Order
trait.
It appears that the problem goes away if either:
sbt-console
in my project directory. Opening the sbt-console
automatically compiles the project sources. Then return to Intellij and re-run the worksheet.I was under the impression that the worksheet was being compiled on the fly every time I re-run it and thus manually compiling it should be un-necessary. Is this incorrect?
In the Project tool window, right-click a Scala library class that you want to decompile. From the context menu, select Decompile Scala to Java. IntelliJ IDEA converts code to Java and opens the converted file in the editor. You can also open the library class in the editor and use its context menu for the conversion.
A worksheet is a scala file with . sc extension which you can run and get evaluation results in a special view appeared in the editor. Create worksheet by right-clicking on your Project and choosing 'New' -> 'Scala Worksheet'. Just type your code, press 'Evaluate worksheet' button and results appear.
Delegate a Scala project build to sbtPress Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.
As mentioned in this discussion thread, in order for a worksheet to find changes to your source classes you need to manually check the "Make project" box which will force a recompile of sources prior to running the worksheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With