IntelliJ:Scala工作表不会重新启动代码更改 [英] IntelliJ: Scala worksheet don't pick up code changes without restart

查看:139
本文介绍了IntelliJ:Scala工作表不会重新启动代码更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Intellij的Scala工作表顶部导入对象的内容,当我向对象添加新内容时,在工作表中找不到它们。即使在我构建项目并重新评估工作表之后,它也找不到新属性。自动填充功能。如果我退出并重新启动IntelliJ就行了。

If I have the contents of an object imported at the top of a Scala worksheet in Intellij, when I add new things to the object, they cannot be found in the worksheet. Even after I build the project and reevaluate the worksheet, it can't find the new property. Autocomplete works. If I quit and restart IntelliJ it works.

这是错误:

java.lang.NoSuchMethodError: Arith$.foo()Ljava/lang/String;
    at #worksheet#.get$$instance$$res6(ArithWS.sc:15)
    at A$A1$.main(ArithWS.sc:41)
    at #worksheet#.#worksheet#(ArithWS.sc)

奇怪的是,它似乎在编译,但在运行时失败。这是一个正常的SBT项目。 IntelliJ 2017.2.5,Scala 2.12.3。选择生成项目复选框没有帮助。实际上,没有复选框的组合使它工作。重建项目或工作表无论如何都无济于事。只有重新启动IntelliJ才能使工作表获取新代码。

Weirdly, it seems to compile, but fails at runtime. This is a normal SBT project. IntelliJ 2017.2.5, Scala 2.12.3. Selecting the "Make project" checkbox doesn't help. Actually no combination of checkboxes makes it work. No amount of rebuilding the project or the worksheet helps either. Only restarting IntelliJ will get the worksheet to pick up the new code.

Arith.scala中的示例项目代码:

Example project code in Arith.scala:

object Arith {
  val foo = "foo"
}

示例工作表ArithWS.sc:

Example worksheet ArithWS.sc:

import Arith._

foo


推荐答案

这似乎解决了它,尽管我会 love 知道默认设置被破坏的原因,或者这个未记录的设置的作用:转到文件 - >设置 - >语言&框架 - > Scala - >工作表(选项卡)。取消选择在编译器进程中运行工作表。

This seems to fix it, though I would love to know why the default setting is broken, or what this undocumented setting does: Go to File -> Settings -> Languages & Frameworks -> Scala -> Worksheet (tab) . Unselect "Run worksheet in the compiler process".

这篇关于IntelliJ:Scala工作表不会重新启动代码更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆