Attaching Sources to a Scala Project on IDEA Intellij
Last updated:It's very useful to be able to hit Ctrl+ click on an identifier and be taken to the source file where it was defined.
I think it's a very good way to learn new things (you'll see great ideas but also bad code) and you need to get used to looking at third-party source code to troubleshoot problems as they happen.
While this is straightforward in scripting languages (python, PHP, ruby, etc), it's not as easy as in Java/Scala JVM Languages because third-party code generally comes in the form of jars (JVM bytecode) rather than source files.
You can attach sources for third-party code (if you have them) to IDEA
I've not yet nailed down what exactly works but here are the main suggestions:
Main suggestion
Re-importing a project
- Close your current project. Once you close it, you'll be taken to the initial screen, where you can click on Import Project
- Re-import the project you're currently working on: select your project root again, select SBT Project and then tick the checkbox where it says "Download sources and docs" et voilà
- At this point, IDEA will look for sources in the directory where SBT keeps jars and sources (on ubuntu, it's
~/.ivy2/
) and, if it doesn't find the sources for the jars in there, it will download them.