简体   繁体   English

在 IntelliJ IDEA 中为 Scala 项目附加源

[英]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以触​​发索引(如果没有自动完成)

reference 参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在IntelliJ IDEA(社区版)中使用Scala源代码构建Android项目? - How to build Android project with Scala sources in IntelliJ IDEA (Community Edition)? 如何将源附加到 Intellij Idea 的 scala sbt 项目? - How to attach sources to scala sbt project at Intellij Idea? 告诉IntelliJ IDEA我想要一个Scala项目的库源 - Tell IntelliJ IDEA I want library sources for a Scala project after the fact 如何在sbt项目中使用来自其他位置的Scala源并将其与IntelliJ IDEA一起使用? - How can I use scala sources from a different location in a sbt project and also make it work with IntelliJ IDEA? 如何在intellij想法中通过maven集成编译scala源代码? - How to compile scala sources via maven integration in intellij idea? 在IntelliJ IDEA中创建Scala项目时出现问题 - Issues while creating Scala Project in IntelliJ IDEA 调试Scala项目(IntelliJ Idea 12和sbt) - Debugging a Scala project (IntelliJ Idea 12 and sbt) Intellij IDEA Java / Scala项目子包显示 - Intellij IDEA Java/Scala project subpackage display 用于在IntelliJ IDEA中创建Scala项目的Scala主目录 - Scala home directory for creating Scala project in IntelliJ IDEA IntelliJ Idea Maven项目中Scala模块的Scala签名错误 - Scala signature error for Scala module in IntelliJ Idea Maven project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM