Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use my classes from Scala worksheet in IntelliJ CE with Scala plugin?

I can not use my classes from Scala worksheet in IntelliJ CE with Scala plugin.

I do the following:

  1. Create Scala SBT project.

  2. In src/main/scala create package test1.

  3. In this package create class

package test1
class TestClass {
}
  1. In the same package create Scala worksheet ws1.sc, inside it create object ws1, inside it put a couple of expressions. It works.

Screenshot 1

  1. When I add new ScalaTest to object ws1, IntelliJ adds import test1.ScalaTest, but evaluation of worksheet does not work.

Screenshot 2

If I add package test1 to my worksheet, it does not work at all, with warning "Package name doesn't correspond to directories structure, this may cause problem with resolve to classes from the file"

Screenshot 3

Is there any ideas how to use my classes from worksheet?

like image 472
tse Avatar asked Oct 29 '14 05:10

tse


People also ask

What is a Scala worksheet?

A worksheet is a Scala file that is evaluated on save, and the result of each expression is shown in a column to the right of your program. Worksheets are like a REPL session on steroids, and enjoy 1st class editor support: completion, hyperlinking, interactive errors-as-you-type, etc.

How do I get Scala plugin in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.


1 Answers

You can use eclipse compatibility mode:

Settings → Languages & Frameworks → Scala → Worksheet → use "eclipse compatibility" mode

like image 122
Yury Kirienko Avatar answered Oct 22 '22 17:10

Yury Kirienko