Viewing Scaladoc in Eclipse - eclipse

In Eclipse I have set the Javadoc Location property of my Scala project to file:/D:/EclipseWorkspace/MyProject/target/scala-2.9.1/api where D:/EclipseWorkspace/MyProject is the location of my scala project.
Now, if I am in a Scala file that implements a class/trait, when I type Shift+F2, Eclipse opens the Scaladoc page of that class/trait. However, this does not work if it is an object since Eclipse tries to open <ObjectName>.html whereas the Scaladoc-generated file name is <ObjectName>$.html.
Is there any workaround?

Scaladoc is now integrated since release 4.0.0 RC1 of the Scala-IDE plugin. You can just hover over your term, or press F2 while the cursor is on the identifier.

Typesafe has announced a plugin for the Scala compiler which generates JavaDoc for your Scala API. The plugin and its documentation is available on github. Maybe this helps as a workaround.

Related

Scala Docs in IntelliJ

How do I access Scala docs in IntelliJ? The other answers in SO are for earlier versions. I added the scala doc jar file, but still I am unable to link scala docs with IntelliJ.
I do get the Quick Documentation as shown:
But I want the complete doc as here
Also, clicking on the Actor hyperlink shows me this code, but not the API doc. There are the download and Attach sources link and I dont understand what they are.
What do you mean by "link scala docs"? You can get documentation for a symbol (class, method) by pressing Ctrl-Q (or menu View > Quick Documentation). This seems to work at least with sbt based projects, even if in Project Structure > Project Settings > Libraries > SBT: org.scala-lang:scala-library:2.12.1:jar there is only classes and sources, and no explicit pointer to javadocs (I guess IntelliJ might extract them directly from the sources).
Also, are you using the latest version of IntelliIJ and the Scala plugin? For me, if I create a global Scala SDK (which you don't actually need when you use sbt build projects), IntelliJ by default does not have javadocs checked, but sources, and again I think it will extract the documentation from the sources. This is how it looks here with IntelliJ IDEA 2016.3.1 and Scala plugin 2016.3.5:
I added this:
to make it work. From the +, choose Scala SDK, select the version that matches your project and then add it to the module of your choice.

Link to library for Scala parser combinators in Eclipse

I created an Eclipse project using parser combinators using Scala 2.10. Recently I upgraded the Scala IDE plugin in Eclipse to version 3.0.4, which includes Scala 2.11. This new version of Scala has removed the scala.util.parsing.combinator package from the core Scala library. As a consequence, my upgraded Eclipse project has a plethora of "not found" errors.
The Scala website has some instructions for adding Maven and SBT dependencies for parser combinators. However, I can't find any instructions on scala-lang.org or scala-ide.org for linking to parser combinators. The full download of Scala (http://www.scala-lang.org/download/) includes a JAR for parser combinators, but I can't find the source attachment JAR for debugging. The Scala Eclipse plugin lacks the parser library (even though it includes other spun-out libraries like Scala Swing). I don't want to use Maven or SBT.
What is the easiest way to add Scala parser combinators (including source attachment) to an Eclipse project?
The easiest way is to use Sbt or Maven. Otherwise you need to manually download the jar file and corresponding sources from here.
You can add the scala-parser-combinators.jar to your build path (Project Properties -> Java Build Path), and then go to Libraries, click on Add External Jar. Once you have the jar, navigate to Source Attachment under the jar name and double-click to attach sources.
Please take my example projects as a starting point. They are using sbt so you can import them into Eclipse.
The 1st is a relatively simple expression parser https://github.com/scala-szeged/top-calc-dsl
The 2nd is a complete example language interpreter in 200 lines handling nested if, while, int, bool, array and variables https://github.com/scala-szeged/hrank-while-language

Scala Compiler not found in Intellij IDEA 11 with Play 2.0 project

I created a project using the typical play new, and then I used play idea to generate the .iml file. When I imported the .iml file into Intellij IDEA, I could not figure out how to get the compiler library to recognize. Below are some screenshots:
Please help!
This is a slight weirdness with the Scala settings in IntelliJ. Currently the only way to register a scala distribution is to create a new project.
Steps:
File > New Project > Create project from scratch
Leave all settings as default. Project name can be anything.
On the "Please select the desired technologies" page, choose Scala. Some GUI elements will appear that allow you to tell IntelliJ how to find your scala compiler and library. Make sure to set the "Level" options to "global".
Click Finish. Close the dummy project that you created, and go back to your real project. The Scala compiler that you registered should now be in the list on your project settings page.
A variation that worked for me: drop the Scala facet and run 'Add framework support...' again.
File / Project Structure / Facets
Click Scala facet then minus to remove Scala facet from your module. Click OK.
Right click your project/module, 'Add Framework Support...', choose Scala.
Enter the path to your Scala compiler and library.
I also ran into this problem, but the workaround as described by Chris B did not work for me, since in my case "Scala" was missing on the "Please select the desired technologies" page.
In my case the problem appeared to be an incompatible Scala plugin. After I reinstalled the Scala plugin it worked fine.

How to run scala code on Intellij Idea 11?

I am new to intellij idea and I decided to shift because I found the scala plugin on eclipse to be annoyingly buggy.
But, intellij idea, which I have heard to be very good, looks difficult to use.
I looked through the getting started with scala plugin page but couldn't find documentation specific to the latest version of lightweight ide of intellij idea 11 for scala.
I have created a project and made a hello world object in scala but I am not able to run it.
On trying to run it, it shows the scala interpreter (type in expressions to get them evaluated).
I don't exactly understand what changes to make in the project structure to be able to run scala code. As of now, i added the jsdk to point to my $JAVA_HOME and the scala library is also added. The scala plugin is also working in that syntax highlighting etc is fine.
The intellij idea user interface is also not very friendly and I don't get how to run the code. What modules am I supposed to add? Also, does compiled scala code run with jvm?
I'll be grateful to anyone who helps out.. I have been putting off writing scala code because I am not able to find THE IDE.
EDIT: Thanks for all the help! I am now able to run a basic scala program. I am trying to add external jars. What is the equivalent of doing Project right click-> Configure Build Path -> adding external jar files in eclipse? I tried adding "dependencies " under modules tab in project structure. It's adding the jar files but somehow the classes in the jar files are not still recognised.
With the Scala plugin installed either
A. Create a new project and select the Scala facet in the creation phase. It will create the Scala library lib and Scala compiler lib and setup the facet for you
B. If you already have a project. Go to Project Structure -> Modules and right click the module and go Add facet and add a Scala facet. Now you need to add scala-library.jar as a library of the module and go into the Scala facet and point it to a library containing scala-compiler.jar
Some more information
this is what your module should look like under project settings
select the Scala facet and this is what you should see (Library name for the compiler is unimportant as long as it says (version xxx) next to the library name
these are the jar files in my scala-compiler lib
and these are the jar files in my scala-library lib
With everything setup like that you should be able to right click -> new Scala class (Select object from the dropdown) in a source directory and add
def main(args:Array[String]) {
println("Hello world")
}
then right click on the class and select Run Classnam.main() and IntelliJ will setup a run configuration for you.
Edit: I can see someone posted somewhat the same I want to say here. I hope this can give a few more in-depths hints, so I will post it anyway :-)
If you would like to run Scala native in IntelliJ (I shifted to IntelliJ and still can't get my hands down) you need to make sure a few things are in order. Most of this happens under File -> Project Structure which requires you to create a project (when you get a hang of it, it is much more logical than Eclipse -- and Netbeans for that matter). I am also assuming you have selected a jdk, but this can also be done in the Project Structure.
Now, to Scala:
Make sure you have the Scala plugin. Visit the Settings (File -> Settings; can also be found at the start-up screen) and locate 'Plugins' (for me it's nr. 8 from the bottom). Under "Browse Repositories" you should be able to search for "scala", find and install a plugin.
1 A. If no plugins pops up you are probably using a version of intellij where scala is not (yet) supported. If that happens you can go to the homepage for the plugin and download the nightly build.
Import Scala as a library in File -> Project Structure -> Global Libraries. Click the plus sign, select Java (Scala is a Java-lib), browse to your scala-dir (which can be downloaded here: http://plugins.intellij.net/plugin/?id=1347) and select the lib directory. Press ok and you should see the library popping up on the list.
Make sure the facet (Scala framework) is in place. Goto File -> Project Structure -> Facets. Click on the plus-sign and find Scala. A sublink should appear (if not double-click the Scala link). Clicking the sublink make sure you have selected a compiler before continuing. This should be provided by the modules selected before. I normally use FSC (Fast Scala Compiler) but it's probably a good idea to test the basic settings before experimenting.
Make sure the Scala Module is in place. In Project Structure -> Modules click on the module you want to compile in scala and click the plus icon above and select Scala. Again be sure to select a compiler library.
If you want to, setup configurations for the compiler under the facet
Use sbt with sbt-idea plugin to generate idea project files for complex projects.
Or
For simple projects.
Add scala nature to the project, and you can right click and run any file extending App.
A good walk-through on how to set up a Scala project in Intellij is located here:
http://sonyarouje.com/2011/03/18/running-scala-in-intellij-idea-10/

Set up Scala for NetBeans - Error

I'm interested in the language Scala and would like to test it with NetBeans Can 6.8. I've downloaded Scala 2.8.0 final und unzipped it to my hard drive. Then I installed the Scala plugin for NetBeans and created a first project. Naturally compilation failed with this message:
You must set SCALA_HOME or environment
property and append
"-J-Dscala.home=scalahomepath"
property to the end of "netbeans_default_options" in
NetBeansInstallationPath/etc/netbeans.conf
to point to
Scala installation directory.
I read what the NetBeans Wiki and the Scala website say to the plugin.
I've added a new environment variable $SCALA_HOME that points to D:\Tools\scala-2.8.0.final
I've added $SCALA_HOME\bin to my path variable
I've edited the netbeans.conf file by adding "-J-Dscala.home=D:\Tools\scala-2.8.0.final" to the end of netbeans_default_options
With your great help this error was fixed. However there are two new problems:
Code Completion doesn't work
2.
After creating a Scala Object this
package scalaapplication1
object te {
}
is not accepted. NetBeans complains
that
type ScalaObject is not a member of
package Scala
Strange: the Netbeans Wiki on Scala doesn't mention "scala.home", only the environment variable SCALA_HOME.
So does the tutorial on Scala plugin installation:
After that, you need to make sure Netbeans is launched from a new dos session (one that has registered the new environment variable definition), and is "path-aware" (like this issue 175394, even though it only concerns Unix platform).
DarrenWang mentions in his article the NBModules plugins to more easily manage those options like "-J-Dscala.home = scalahomepath" in the netbeans.conf file.
But it experienced some crashed with the Scala plugin and the latest Netbeans.
Can you read Chinese? hehe, I wrote down something here:
http://www.zeuux.com/group/scalaba/bbs/content/4240/