Attaching sources in IntelliJ IDEA for scala project
Asked Answered
M

5

13

I have Playframework 2 project with Scala (very small one). It uses Scala Anorm library.

I have the code like this:

package models
..
import anorm.SqlParser._
...

val rowParser = scalar[Long]

So, I would like to see source of scalar method. Trying to attache the sources I have in my plaframework source folder, but IDEA just swallows my request and does nothing back.

I use last version of IDEA and Scala plugin. Is it bug, probably?

Majestic answered 22/11, 2012 at 21:59 Comment(1)
yes this appears to be brokenHaymo
M
11

Aha.. fixed.

So: I used to use 'attach source' in the top of the window editor - it does not work (I guess it is a bug - maybe related to the scala plugin, because usually it works).

But if try to attache sources to particular library - in "Project Structure -> Library -> +Attach File or Directories -> Sources" then it works.

Thanks.

Majestic answered 22/11, 2012 at 22:30 Comment(2)
This is STILL not working.. WHEN WILL THIS BE FIXED!Haymo
If install scala --with-src using homewbrew, you set source directory path File > Project structure -> libraries -> scala-library -> Sources -> '+' button -> /usr/local/opt/scala/idea/src -> then press ok. Make sure when install scala with brew option --with-src, --with-docs.Binate
I
13

First download source code :

1.) Click on this link : http://www.scala-lang.org/download/all.html

2.) Choose any scala version.

3.) Now in the last section 'Other Resources' you can see 'Sources' link. Click on it to download. In my case (https://codeload.github.com/scala/scala/tar.gz/v2.11.7)

enter image description here

Now point to this Source Code from IntelliJ.

1.) Open Project Structure in IntelliJ. Shorcut (Cmd + DownArrow)

2.) Select Global Libraries from the left section.

3.) Then on right side, Under 'Scala Library' section. Click '+' and point to source directory. See the screenshot.

enter image description here

Indefeasible answered 9/7, 2015 at 8:40 Comment(1)
Thanks for this tip, it helped me with another problem - i needed to also unzip the gzipClariceclarie
M
11

Aha.. fixed.

So: I used to use 'attach source' in the top of the window editor - it does not work (I guess it is a bug - maybe related to the scala plugin, because usually it works).

But if try to attache sources to particular library - in "Project Structure -> Library -> +Attach File or Directories -> Sources" then it works.

Thanks.

Majestic answered 22/11, 2012 at 22:30 Comment(2)
This is STILL not working.. WHEN WILL THIS BE FIXED!Haymo
If install scala --with-src using homewbrew, you set source directory path File > Project structure -> libraries -> scala-library -> Sources -> '+' button -> /usr/local/opt/scala/idea/src -> then press ok. Make sure when install scala with brew option --with-src, --with-docs.Binate
C
2

To fix it we need to do some changes into IntelliJ IDEA platform. Most probably it will be fixed in IntelliJ IDEA 13.1.

Comment answered 31/1, 2014 at 9:52 Comment(1)
I really need this. When will this be fixed??Haymo
A
1

I have the same problem. I installed "Scala Imports Organizer", and problem was solved.

Acey answered 10/10, 2014 at 8:6 Comment(0)
P
0

for "automatically attaching source jars" when using Bloop and BSP you can add one line:

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

to your build.sbt, also sbt updateClassifiers, also Reload all BSP Projects to refresh, also Invalidate Caches/Restart to trigger indexing (if not done automatically)

reference

Patch answered 7/4, 2021 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.