[英]Attaching sources in IntelliJ IDEA for scala project
I have Playframework 2 project with Scala (very small one).我有 Scala 的 Playframework 2 项目(非常小的项目)。 It uses Scala Anorm library.它使用Scala Anorm库。
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.试图附加我在我的 plaframework 源文件夹中的源,但 IDEA 只是吞下了我的请求并且什么都不做。
I use last version of IDEA and Scala plugin.我使用最新版本的 IDEA 和 Scala 插件。 Is it bug, probably?大概是bug吧?
First download source code :首先下载源代码:
1.) Click on this link : http://www.scala-lang.org/download/all.html 1.) 点击这个链接: http : //www.scala-lang.org/download/all.html
2.) Choose any scala version. 2.) 选择任何 Scala 版本。
3.) Now in the last section 'Other Resources' you can see 'Sources' link. 3.) 现在在最后一部分“其他资源”中,您可以看到“来源”链接。 Click on it to download.点击它下载。 In my case ( https://codeload.github.com/scala/scala/tar.gz/v2.11.7 )就我而言( https://codeload.github.com/scala/scala/tar.gz/v2.11.7 )
Now point to this Source Code from IntelliJ.现在指向这个来自 IntelliJ 的源代码。
1.) Open Project Structure in IntelliJ. 1.) 在 IntelliJ 中打开项目结构。 Shorcut (Cmd + DownArrow)快捷键 (Cmd + DownArrow)
2.) Select Global Libraries from the left section. 2.) 从左侧选择全局库。
3.) Then on right side, Under 'Scala Library' section. 3.) 然后在右侧,在“Scala 库”部分下。 Click '+' and point to source directory.单击“+”并指向源目录。 See the screenshot.看截图。
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).所以:我曾经在窗口编辑器的顶部使用“附加源” - 它不起作用(我猜这是一个错误 - 可能与 scala 插件有关,因为通常它可以工作)。
But if try to attache sources to particular library - in "Project Structure -> Library -> +Attach File or Directories -> Sources" then it works.但是,如果尝试将源附加到特定库 - 在“项目结构 -> 库 -> +附加文件或目录 -> 源”中,则它可以工作。
Thanks.谢谢。
To fix it we need to do some changes into IntelliJ IDEA platform.要修复它,我们需要对 IntelliJ IDEA 平台进行一些更改。 Most probably it will be fixed in IntelliJ IDEA 13.1.它很可能会在 IntelliJ IDEA 13.1 中修复。
I have the same problem.我也有同样的问题。 I installed "Scala Imports Organizer", and problem was solved.我安装了“Scala Imports Organizer”,问题解决了。
for "automatically attaching source jars" when using Bloop and BSP you can add one line:对于使用 Bloop 和 BSP 时“自动附加源 jars”,您可以添加一行:
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)到您的build.sbt
,还有sbt updateClassifiers
,也Reload all BSP Projects
以刷新,也使Invalidate Caches/Restart
以触发索引(如果没有自动完成)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.