gpt4 book ai didi

scala - 如何配置 IntelliJ Scala 插件以使用 Scala 的 native 演示编译器?

转载 作者:行者123 更新时间:2023-12-04 01:30:38 24 4
gpt4 key购买 nike

虽然IntelliJ Scala Plugin使用 Scala 编译器正确生成实际的字节码,它似乎使用 its own实现presentation compiler提供实时type-aware error highlighting在编辑器中:

syntax highlighting feature that is implemented by Idea's Scala plugin and it requires immediate re-processing of all the files you change in a way similar but now exactly the same as what the real compiler does.

这可能是有时项目构建成功但 IntelliJ 在编辑器中显示误报红色下划线的原因。即使 use sbt shell 似乎也是如此。被公开票选为明显SCL-11079

By default, the sbt compile should mark additional errors it finds in the editor and project view. False positive errors reported by the internal annotator should be removed if possible. There should be an option to use sbt output as the "single source of truth" for highlighting errors, at the cost of instant error highlighting.

或者如果项目导入为 BSP project

sbt shell indeed won't help with error highlighting in the editor, nor will BSP (for the time being). In-ide highlighting uses a method that is completely separate from regular compilation

无论如何配置 IntelliJ 以开箱即用地使用 Scala presentation compiler而不是它自己的自定义实现,这样我们就可以减少类似于 Metals 的误报错误的机会。提供?

最佳答案

根据 show bsp diagnostics in editor SCL-16610存在一个 IntelliJ 注册表标志

scala.highlighting.compiler.errors.in.editor

启用 experimental特征

As error highlighting using the built-in parser and type-checker continues to be a problem for the Scala plugin, we can experiment with using compiler output from BSP... Potential downsides: Less rich error highlighting on type mismatch problems: BSP and the compiler expose only raw string messages and positions. We would lose type diffs and type error hints.

这是让它在我的机器上运行的步骤

  1. 安装 JetBrains Toolbox允许在发布的同时安装抢先体验程序(这样您就可以在出现任何问题时恢复到您的工作系统)
  2. 安装 2020.1
  3. 确保 Nightly Builds 更新 channel 已在 Preferences | 下设置语言与框架 |斯卡拉 |更新

    enter image description here

  4. 从项目的根目录中删除 .idea:rm -fr .idea
  5. 重新导入项目并选择BSP项目

    enter image description here

  6. 如果一切正常,项目根目录下应该有.bloop目录
  7. 打开 IntelliJ 注册表:帮助 |查找操作... |注册表
  8. 设置键 scala.highlighting.compiler.errors.in.editor

    enter image description here

关于scala - 如何配置 IntelliJ Scala 插件以使用 Scala 的 native 演示编译器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61099741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com