Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

at scala project, compiler error - Cannot resolve symbol List?

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?

  • How to solve this trouble?

Update:

  • I reinstalled newly version of IntelliJ IDEA 13 Community Edition instead of # 12. Untared in /usr/local/Idea.
  • Removed sbt - 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.

  • And opened this project with idea greeting window (Open Paroject). Of course, installed 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. enter image description here

like image 609
catch23 Avatar asked Sep 23 '13 13:09

catch23


2 Answers

For anyone having the same problem, start by trying the following in Idea:

File -> Invalidate Caches -> Invalidate and Restart

like image 74
Jack Avatar answered Oct 18 '22 14:10

Jack


If your IDEA plugin doesn't see scala classes then go to File -> Project Structure and check the following:

  1. 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.

  2. Make sure the Scala Facet uses the right version of your scala library (Idea will mark it with red, if it cannot be found).

  3. Make sure scala-library.jar is on the list of dependencies of the modules using Scala. Check if paths are ok.

like image 25
Piotr Kołaczkowski Avatar answered Oct 18 '22 13:10

Piotr Kołaczkowski