`Cannot find symbol` in IntelliJ 14 - scala

I have use the IntelliJ Scala plugin before, in 13 and 13.1. I upgraded to 14, and it doesn't work anymore for my SBT project.
For all Scala standard lib stuff, I see errors like "Cannot find symbol scala.Option".
at scala project, compiler error - Cannot resolve symbol List? says I need to have the Scala facet for my module. I looked in facets, and Scala wasn't an option.
I've uninstalled IntelliJ and the Scala plugin and my settings and the projects files multiple times, but still happens.
How do I fix this?

the new scala plugin for intellij 14 removed the facet and replaced it with Scala SDK library, see blog
for sbt project, I guess the best bet is to re-create your project by:
File -> open -> select the build.sbt of your project in popup -> delete existing project and import

I had a similar issue when a Java module calls an Scala object. The issue was from the wrong setup in Source Folders; the Scala source was in src/main/scala/..., but in the Project Structure, the Source Folders were setup as src by default. When I changed it as src/main/scala, the Java module can find the Scala object correctly.

I fixed this by using the nightly builds of the Scala plugin.
The fixes have now been incorporated into the stable versions.

In my case i just had to reload the IDE...

Related

Chisel: Compiling Chisel library on Windows

I have been using sbt on windows and a custom build.sbt script in conjunction with an import Chisel._ in the top-level file in order to generate Verilog from my Chisel source successfully.
I'm trying to get an IDE working on Windows to expedite Chisel development. I've gone with the Eclipse based SCALA IDE http://scala-ide.org/download/sdk.html/
I want to compile the Chisel library so that the import Chisel._ can be resolved locally, without having to go off and download the source from the repository each timeand recompile the source. When I download the Chisel-master repo from Git and include the src\main folder in my SCALA project in the SCALA IDE, I get lots of syntax errors in the Chisel SCALA files that prevent me from building the project.
Has anyone done anything like this before on Windows or have any knowledge of working with the SCALA IDE as it may just be a case of undefined symbols in the project configuration?
Not sure exactly what you did with build.sbt respect to recompile (I think it download it only the first time, then it caches it for the future). But I'm using ScalaIDE for Chisel on linux, using the default build.sbt files, maybe you can try to get it working out of the box first to help narrow down the issue.
Here are the steps I took in order to get ScalaIDE work with Chisel:
the latest Scala IDE uses 2.11.8, the current Chisel repository defaults to 2.11.7. So I had to change all the build.sbt reference to scalaVersion from 2.11.7 to 2.11.8
I used sbteclipse
https://github.com/typesafehub/sbteclipse
To create importable the workspace to setup the compilation dependencies.
Except for chiselFrontEnd. For some reason, this package is not added to the dependency. I have to Add chiselFrontEnd as a javabuildpath dependency manually (Properties/JavaBuildPath, under Projects) for my own projects.
To resolve undefined symbols, you can also add a JAR onto the project build path using Project Properties > Java Build Path > Libraries > Add External JARs...
If you are getting your JARs through Maven / SBT, they should be in:
C:\Users\<name>\.ivy2\local\edu.berkeley.cs\chisel3_2.11\jars
If you are using publish-local with chisel3, your JARs should be in
C:\Users\<name>\.ivy2\cache\edu.berkeley.cs\chisel3_2.11\jars
Note that chisel3 is compiled into one JAR, including coreMacros and chiselFrontend sub-projects
Of course, this is a more quick-and-dirty solution compared to something that can parse SBT files.

sbteclipse not adding generated source folders to java build path?

I ran sbt eclipse on a Scala Project and when I imported it into Scala IDE(4.0.0 RC2), it gave me a type not found error as the types referred to were actually auto-generated code which were at target/scala-2_10/src_managed/main/compiled_avro/org/... I was able to do a sbt compile at the console though.
I got it to compile by adding the above folder to the Java Build Path.
My question is that since sbt eclipse can already detect Java Projects which the current project depends on and since sbt compile works at the console, should sbt eclipse be able to figure out dependencies to source folders of generated code as well? or maybe such a feature exists and I just don't know about it?
This may not be the correct way of doing things but to fix the issue i did the following.
sbt avro:compile
sbt compile
sbt eclipse
In eclipse i right clicked on target/scala-*/src_managed/main/compiled_avro > build path > use as source folder
The sbteclipse way:
Edit your project or global build.sbt file. My global ~/.sbt/0.13/build.sbt contains:
import com.typesafe.sbteclipse.plugin.EclipsePlugin._
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Managed
I'm using an older version of _sbteclipse, version 2.5.0 (various non-relevant reasons), which seems to require both the import and a single blank link between each line of real content (this drives me a bit crazy, yes). I don't believe the import is required for newer versions of sbteclipse.
sbt clean avro:compile compile
sbt eclipse

Play with Activator Issue on IntelliJ Idea 14

I have the following problem on IntelliJ IDEA 14:
I created a Play (Scala) project using the Activator (v1.2.10). Then, I converted it to an IDEA project using activator idea command. When, I opened the project with IDEA 14 (Community Edition) the SBT module is not enabled. Therefore, a new dependency in build.sbt file is not included in the classpath. Moreover, the project is not listed in IDEA's SBT view.
The following warning is shown by IDEA:
"This IDEA project is converted from an SBT project by gen-idea tool, which currently relies on a legacy Scala project model. Please consider using built-in SBT support via the Import project action."
Note that, the Scala and SBT plugins are already installed on IDEA.
I don't encounter with the same issue in IDEA 13.
Have you tried File | Import Project and select build.sbt file?
IDEA imports it as an SBT project, with all the dependencies properly resolved. It works fine for me on IDEA 14 and on 13.
Apparently, this is a bug in some versions of IntelliJ 14, that just got fixed (as of version 14.0.3). Updating IJ then updating the scala plugin seems to make things work.
In this case simply import manually the "build.sbt" from your project, so if the directory is ~/Documents/myPlayApp then choose to import ~/Documents/myPlayApp/build.sbt

Error: scala: No 'scala-library*.jar' in Scala compiler library

Environment: Play 2.3.0/Scala 2.11.1/IntelliJ 13.1
I used Typesafe Activator 1.2.1 to create a new project with Scala 2.11.1. After the project was created, I ran gen-idea. The generated IDEA project fails to compile with the error:
Error: scala: No 'scala-library*.jar' in Scala compiler library in test
Am I doing something wrong? Workaround?
Open File -> Project Structures -> Libraries, remove any scala sdk in it, e.g. scala-sdk-2.11.8 in the following image.
Click on +, then Scala SDK.
Select the right Scala SDK from the list, for me, it's Ivy-Scala-2.11.8 shown in the picture.
Select the current project(mine is spark-test), click OK.
Then click OK to close it.
Run again, it should work now.
Since IDEA 13 you should use SBT support which is bundled with Scala plugin.
With it there is no need to add third-party SBT plugins and run special commands; just import the project using "File -> Import project..." menu item, and it will automatically load SBT project structure and its dependencies.
I had the same issue with the .idea files generated by ./activator idea with play 2.3. A quick fix is to look in "Project Structure->modules" and note the name of the compiler library. For me it was "SBT: scala2.11.1". The look in "Project Structure->Libraries" and check the contents of this library. It should contain scala-compiler.jar, scala-library.jar, scala-reflect.jar. If this libraries are not present, add them (in my case they are located in ~/.sbt/boot/scala-2.11.1/lib).
For IDEA 15 and project exported from Activator 1.3.5 only Russell's solution helped at the moment.
I have fixed scala compiler library with adding 3 libraries located in ~/.sbt/boot/scala-2.11.1/lib to library's compiler classpath and classes. After indexing project I moved this library to global libraries of IDEA and it was saved there.
I had the same issue.
If you are building your project using external sbt i.e sbt compile then it will create or add dependencies in libraries(all external dependency also) and scala sdk will be added as SBT:scala* based on version of your scala.
So you can remove SDK with SBT as prefix and add proper SDK through Intellij.
File->Project Structure->Libraries
Remove SBT SDK and add it manually.
For me with IDEA 12, I fixed this issue when I unchecked the box for "Use external build" in Settings.Compiler.
now is 2021 year, in Mac, use IntelliJ to run scala:
core logic
Mac: brew install scala
IntelliJ: open *.scala file, then according notice to auto config java JDK and Scala SDK
detailed steps: pls refer another post's answer
I'm an absolute Scala beginner. I was wanting to get up and running. I needed to create a Scala project, not a Java project with Scala library:

IntelliJ plugin for cucumber-scala

I am running Cucumber scala project in IntelliJ
IntelliJ IDEA - 13.0.2
I couldn't find separate plugin called cucumber for scala
In my project I am getting cannot resolve message for cucumber as below
Could see below errors as well
Existing plugins installed
What could be the solution
Cheers
You are missing dependencies for cucumber-core and cucumber-scala, please have a look at the documentation and add them to your build.sbt file.
Update:
There is a newer version available for sbt-cucumber-plugin (0.8.0): https://github.com/skipoleschris/xsbt-cucumber-plugin. Maybe that solves your problems.
Did you try the gen-idea plugin to create the IntelliJ IDEA project files ?