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?

0
14 comments
Avatar
Permanently deleted user

Bill, are you referring to the Scala runtime library itself or a third-party library written in Scala?

0
Avatar
Permanently deleted user

Third-party libraries

0
Avatar
Permanently deleted user

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?

0
Avatar
Permanently deleted user

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.

0

That's a bug. Is it same for any method invocation into third-party library?

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

Any known workarounds?

0
Avatar
Permanently deleted user

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.

0
Avatar
Permanently deleted user

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)

0

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.

0
Avatar
Permanently deleted user

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)?

0

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.

0

to add the sources of libraries (source jars) to the project dependencies ("attach sources"), add

bloopExportJarClassifiers in Global := Some(Set("sources")

to the build.sbt. For reference, see https://scalacenter.github.io/bloop/docs/build-tools/sbt#download-dependencies-sources 

0

Please sign in to leave a comment.