如何配置IntelliJ Scala插件以使用Scala的本机演示文稿编译器? [英] How to configure IntelliJ Scala Plugin to use Scala's native presentation compiler?

查看:109
本文介绍了如何配置IntelliJ Scala插件以使用Scala的本机演示文稿编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管 IntelliJ Scala插件使用适当的Scala编译器来生成实际的字节码,但似乎使用

Although IntelliJ Scala Plugin uses Scala compiler proper to generate the actual bytecode, it seems to use its own implementation of presentation compiler to provide real-time type-aware error highlighting in the editor:

由Idea的Scala实现的语法突出显示功能 插件,它需要立即重新处理您所有的文件 改变的方式与实际相似,但现在完全相同 编译器会这么做.

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在编辑器中显示假阳性红色下划线的原因.即使选择了使用sbt shell ,情况似乎也是如此,如公开票证

This might be the reason why sometimes projects build successfully and yet IntelliJ shows false positive red underlines in the editor. This seems to be the case even if use sbt shell is selected as evident by open ticket SCL-11079

默认情况下,sbt编译应标记它在其中发现的其他错误 编辑器和项目视图.假阳性错误报告由 如果可能,应删除内部注释器.应该有一个 选择使用sbt输出作为单一真相" 突出显示错误,但要以立即突出显示错误为代价.

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项目

sbt shell确实对在编辑器中突出显示错误无济于事, 将BSP(暂时). ide-in突出显示使用一种方法 与常规编译完全分开

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 表示编译器而不是其自己的自定义实现,这样我们就可以减少与

Is there anyway to configure IntelliJ to use Scala out-of-the-box presentation compiler instead of its own custom implementation such that we can decrease the chance false positive errors akin to what Metals provides?

推荐答案

根据显示bsp诊断在编辑器SCL-16610中存在一个IntelliJ注册表标志

According to show bsp diagnostics in editor SCL-16610 there exists a IntelliJ registry flag

scala.highlighting.compiler.errors.in.editor

启用实验性功能

使用内置解析器和类型检查器来突出显示错误 Scala插件仍然是一个问题,我们可以尝试 使用BSP的编译器输出...潜在的弊端:类型不匹配时突出显示的错误较少 问题:BSP和编译器仅公开原始字符串消息,并且 职位.我们将丢失类型差异和类型错误提示.

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.

以下是使它在我的计算机上运行的步骤

Here are the steps that made it work on my machine

  1. 安装 JetBrains工具箱,它可以安装早期访问程序以及发行版(这样,如果出现任何问题,您可以还原到工作系统中)
  2. 安装
  1. Install JetBrains Toolbox which enables installation of Early Access Programs alongside releases (such that you can revert to your working system if anything goes wrong)
  2. Install 2020.1
  3. Make sure Nightly Builds update channel is set under Preferences | Languages & Frameworks | Scala | Updates

重新导入项目并选择BSP项目

Re-import the project and select BSP project

设置键scala.highlighting.compiler.errors.in.editor

这篇关于如何配置IntelliJ Scala插件以使用Scala的本机演示文稿编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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