How do I add source for Scala libraries to an IDEA project?
Event after attaching Scala source code (either source jars or source directories) to my project libraries, when I ctrl-click a library method, I get taken to the ".class" file with just method declarations.
Does this feature work for Scala?
Please sign in to leave a comment.
Please refer to http://blog.jetbrains.com/scala/2010/09/02/project-configuration-explained/
Bill, are you referring to the Scala runtime library itself or a third-party library written in Scala?
Third-party libraries
Using IDEA 10.5 and Scala plugin nightly build 1075, I was able to add the scalatest library to a test project, with source directories attached to the library, add an import for org.scalatest.Spec to a Scala class file in my test project and ctr-click to the source for the Spec class.
Maybe double-check that you're attaching the correct source directories/archives to your library?
So, looking into the problem a little more closely, the source libraries do indeed get added to the project - if I press Cmd-Shift-O ("Go to file"), I can open the Scala source for any file.
However, when I ctrl-click on a method in a third-party library whose source is included in the project, it brings me to the .class file rather then the .scala file.
That's a bug. Is it same for any method invocation into third-party library?
Best regards,
Alexander Podkhalyuzin.
Hi Alexander,
It's the same for every method and library I've tried. Also, if I try to jump to a method from the debugger stacktrace, that takes me to the .class files as well.
Bill
Any known workarounds?
I upgraded to the nightly build of the Scala plugin.
I still get .class files when I control-click, but now clicking a function in the debugger's Frames dialog works. Not sure if that information helps.
Hmm. On further inspection, only some entries in Frames take me to .scala files; many still take me to .class files (this is for methods whose sources are on my path, of course)
It will be great if you find a way to give me some sample project with all dependencies. Then I'll be able to fix it in your case. Or I need more information, maybe for example link to third-party library with some simple usage.
Best regards,
Alexander Podkalyuzin.
I have been trying to set up a scala project using the 2.9.0.1 release (by Typesafe) but just can't get the IDE to open up the source files for the libraries (using CMD-B). Any suggestions (other than the ones allready given in this discussion)?
Unfortunately, I can't reproduce your problem. Can you give me a sample project with your setup to reproduce this problem?
Best regards,
Alexander Podkhalyuzin.
to add the sources of libraries (source jars) to the project dependencies ("attach sources"), add
to the build.sbt. For reference, see https://scalacenter.github.io/bloop/docs/build-tools/sbt#download-dependencies-sources