【问题标题】:How to execute dotty code from Visual Studio Code UI如何从 Visual Studio Code UI 执行 dotty 代码
【发布时间】:2019-07-31 10:06:23
【问题描述】:

我正在尝试使用 Visual Studio Code 运行 dotty 代码。我根据this page 的说明使用sbt launchIDE 启动IDE,并且还安装了Dotty Language Server 和Code Runner 扩展。 Dotty 是使用brew 安装的,我可以从 CMD 编译和执行 dotty 代码。

问题是我无法从Visual Studio Code 运行此代码,因为Code Runner 正在尝试使用scala 而不是dotty 来执行它。

找不到任何有用的配置来调整此插件以使用 dotty。

有什么方法可以让它在 Visual Studio Code UI 中运行?

【问题讨论】:

  • 您的问题需要有关您的环境的更多信息,例如你在什么操作系统上。

标签: scala visual-studio-code dotty scala-3


【解决方案1】:

克隆存储库https://github.com/lampepfl/dotty-example-project(在页面https://dotty.epfl.ch/docs/usage/getting-started.html中提到)并运行

sbt launchIDE

(在https://dotty.epfl.ch/docs/usage/ide-support.html 提及)。

代码应该是run用scala(运行时是一样的)。如果代码是用 scalac 而不是 dotty 编译,这可能意味着 build.sbt 中的 scalaVersion 错误或 plugins.sbt 中未打开 dotty sbt 插件。

build.sbt

lazy val root = project
  .in(file("."))
  .settings(
    name := "dottydemo",
    version := "0.1",
    scalaVersion := "0.13.0-RC1"
)

plugins.sbt

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0")

你也可以试试 IntelliJ IDEA(虽然没有官方支持)Run Scala Dotty project using Intellij IDE

【讨论】:

  • 是的。我所有的配置文件都包含正确的配置和版本,我正在使用sbt launchIDE,但是当我从 UI 执行“运行代码”时,它使用 scala 而不是 dotty 编译代码。也无法从您的屏幕截图中编译代码。 sbt compile 和 sbt run 命令对我很有效。也许我需要在 Visual Studio Code 上添加一些额外的 sbt 扩展。
  • @BogdanVakulenko 您是否设法解决了您的问题?如果有,怎么做?
  • @TimoMeijer 不幸的是,不是。我刚开始使用命令行工具编译和运行。
  • @BogdanVakulenko 我现在正在使用任务(ctrl-shift-p -> 任务)。我为sbt run 和sbt ~run 做了任务,这对我运行/测试代码很有用
猜你喜欢
  • 2015-07-11
  • 2016-12-28
  • 1970-01-01
  • 2022-09-23
  • 2016-07-05
  • 1970-01-01
  • 2019-12-09
  • 2021-06-01
相关资源
最近更新 更多