I'm completely newly at Scala.
I installed java, sbt and scala on Ubuntu 12.04:
nazar_art@nazar-desctop:~$ sbt sbt-version
[warn] Alternative project directory .sbt (/home/nazar_art/.sbt) has been deprecated since sbt 0.12.0.
[warn] Please use the standard location: /home/nazar_art/project
[info] Loading project definition from /home/nazar_art/.sbt
[info] Set current project to default-5b9232 (in build file:/home/nazar_art/)
[info] 0.12.4
nazar_art@nazar-desctop:~$ scala -version
Scala code runner version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL
nazar_art@nazar-desctop:~$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
I installed scala and sbt plugins to Idea.
And when I tried irst example project I see next error:
Cannot resolve symbol List, after next lines:
package example
import common._
object Lists {
def sum(xs: List[Int]): Int = { // <== here underline for List
if (xs.isEmpty) 0
else xs.head + sumList(xs.tail)
}
}
I couldn't figure out what exactly is wrong?
IDEA suggest me importing java.util.List
- but this class doesn't have any isEmpthy()
method.
Any suggestion?
Update:
/usr/local/Idea
.sudo apt-get purge sbt
. And reinstall accord this
script.I went to /MyProjectDirectory/project/
and created 'plugin.sbt'
with content:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
After this I type from my project directory sbt gen-idea
. It
rebuild project for Idea.
sbt
and scala
plugins.It should be enough but it shown again:
Cannot resolve symbol List
and suggesting import import scala.collection.immutable.List
. But this isn't helpful. It keep being underlined with red line.
For anyone having the same problem, start by trying the following in Idea:
File -> Invalidate Caches -> Invalidate and Restart
If your IDEA plugin doesn't see scala classes then go to File -> Project Structure and check the following:
Make sure the Scala Facet is added to your application. Go to the Facets tab and check if Scala facet is listed there. If not, you need to add and configure it. Then make sure that Scala Facet is listed under all the modules that need Scala.
Make sure the Scala Facet uses the right version of your scala library (Idea will mark it with red, if it cannot be found).
Make sure scala-library.jar is on the list of dependencies of the modules using Scala. Check if paths are ok.
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