生态系统中有无数的开发工具和术语,例如语言服务器、构建服务器、Metals、BSP、LSP、Bloop、Zinc、Coursier、增量编译器、演示编译器等。
我想知道是否有人可以演示它们如何组合在一起并简要解释关系和差异。具体来说,我希望按照“理解 Scala FP 库”的思路给出图表和答案。例如,这是我的尝试
(Concept) (Example implementation)
--------------------------------------------------------------------
IDE Visual Studio Code
| |
Scala IDE plugin Metals Visual Studio Extension
| |
Language Server Protocol Microsoft LSP
| |
Scala language server Metals
| |
Build Server Protocol BSP from JetBrains and Scala Center
| |
Scala build server Bloop
| |
Build tool sbt
| |
Dependency resolution Coursier
| |
Incremental compiler Zinc
| |
Presentation compiler parser and typer phases of scalac
| …Run Code Online (Sandbox Code Playgroud) development-environment scala build-tools incremental-build scala-metals
有没有办法在 vscode 中使用金属 scala 插件,运行特定的测试场景?就像在 IntelliJ 中一样?
我希望能够使用 VsCode 远程调试在 Docker 容器中运行的 Scala 编写的 Spark 作业。这就是我到目前为止所拥有的
docker exec -it -e SPARK_SUBMIT_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=4000 -w /spark spark-job-starter_master_1 bin/spark-submit --class example.StarterSparkJob /build/example.jar
Run Code Online (Sandbox Code Playgroud)
这样做后我看到输出Listening for transport dt_socket at address: 4000
Debugger failed to attach: handshake failed - received >Content-Length< - expected >JDWP-Handshake<
Run Code Online (Sandbox Code Playgroud)
代码的完整详细信息位于https://github.com/aedenj/spark-job-starter/tree/vscode-debug-setup。感谢您的指导。
scala apache-spark visual-studio-code vscode-debugger scala-metals
我的多项目 sbt 存储库中有 scala 格式插件。
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
Run Code Online (Sandbox Code Playgroud)
所以在 sbt 控制台中如果我运行 scalafmt 它工作正常
我的 build.sbt 有:
scalafmtOnCompile := true
Run Code Online (Sandbox Code Playgroud)
如果我在 sbt 中执行 ~compile 或只是手动编译,它不会在编译期间格式化我的代码。
我的设置有什么问题吗?
另外,运行 scalafmt 可以工作,但它不会像我的 Dependency.scala 文件那样格式化 /project 中的 .scala 文件。为什么它忽略这些文件?
我也使用带有金属的 VS Code 作为我的 IDE。
Metals 宣布“现在可以使用新的“运行”、“测试”、“调试”和“调试测试”按钮直接从 VS Code 运行和测试。” 有一个很好的 gif 显示它可以做什么,我不知道如何达到这一点。
我尝试使用以下配置启动 VS Code 调试器 launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "scala",
"request": "launch",
"name": "Untitled",
"mainClass": "com.playZip.Unzip",
"args": [],
"jvmOptions": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
并收到此错误消息:
Couldn't find a debug adapter descriptor for debug type 'scala' (extension might have failed to activate)
Run Code Online (Sandbox Code Playgroud)
Gitter scalameta/metals上有人遇到了这个问题,答案是他需要 Bloop 来支持 utest,我认为我的需要,因为 …
我正在尝试在 vscode 上运行 Scala 程序。我尝试下载 Scala(金属)扩展,但出现以下错误。
无法下载 Metals,请确保您有互联网连接并且 Java Home 'C:\Program Files (x86)\Java\jdk1.8.0_144\bin' 有效。您可以在设置中配置 Java Home。如果您使用 HTTP 代理,请参阅https://scalameta.org/metals/docs/editors/vscode.html#http-proxy了解说明。
我没有使用任何代理。我检查了环境变量,并将 JAVA_HOME 系统变量设置为“C:\Program Files (x86)\Java\jdk1.8.0_144\bin”
我的机器上安装了 Java 8,但 VSCODE 上没有安装。这会是个问题吗?
我正在尝试将Scala与Java进行互操作,并成功创建了一个基于Maven的项目(此处为存储库),该项目可以从命令行 ( mvn clean package) 进行良好的编译。
然而,我一直遇到这样的问题:我的 IDE(VS Code)根本不理解互操作。
该文件AccessScala.java正在尝试访问 中的变量WithinModule.scala。
package me.parent.jModule;
import me.parent.jModule.WithinModule;
public class AccessScala {
public static void main(String[] args) {
WithinModule within = new WithinModule();
// -- this is like a static variable, but Scala doesn't allow that
// System.out.println(WithinModule.string());
// -- this is the auto-generated getter
System.out.println(within.string());
// -- this getter was manually added
System.out.println(within.getString());
}
}
Run Code Online (Sandbox Code Playgroud)
VS Code 引发了三个问题: …
此代码确实使用 mill 进行编译和运行,但智能感知显示错误“object pwd is not a member of package foo.os bloop”
//main.scala
package foo
object Exercise{
def main(args: Array[String]): Unit = {
println(os.pwd)
}
}
Run Code Online (Sandbox Code Playgroud)
//build.sc
import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.13.1"
def ivyDeps = Agg(
ivy"com.lihaoyi::os-lib:0.7.8"
)
}
Run Code Online (Sandbox Code Playgroud)
我有 Metals vscode 扩展,它确实可以识别项目库中的 os-lib 。它确实显示了 os.pwd 的类型,但仍然显示错误。
根据标题,如何在 (n)vim 中手动触发Scala Metals 的构建导入查询?
Metals 通常在写入更改build.sbt或相关文件时进行查询,但是当我决定取消查询(空条目)或在上次导入完成之前再次写入时,它无法再次查询。因此,我希望能够手动触发构建导入。但如何呢?
scala ×9
scala-metals ×9
java ×2
sbt ×2
apache-spark ×1
build-tools ×1
java-8 ×1
maven ×1
mill ×1
scalafmt ×1
vim ×1