在 Scala 插件中控制错误的 IntelliJ 代码编辑器错误

在 Scala 插件中控制错误的 IntelliJ 代码编辑器错误

问题描述:

我有从 ANTLR4 生成的 Java 代码.Scala 通过扩展一些方法来使用 Java 代码.问题是IntelliJ的scala插件好像不知道Java基类和Scala子类的关系,显示误报错误信息;当 Scala 覆盖 Java 方法时,它会报告方法......覆盖任何内容".

I have Java code generated from ANTLR4. Scala is using the Java code by extending some of the methods. The issue is that IntelliJ's scala plugin does not seem to know the relationship between Java base class and Scala subclass to show a false positive error message; it reports "Method ... overrides nothing" when Scala overrides Java method.

如何控制 IntelliJ 中的错误级别以抑制此错误消息?

How to control the error level in IntelliJ to suppress this error message?

Scala 插件产生的大部分误报都是由类型感知突出显示引起的:

Most of the false-negatives produced by Scala plugin are caused by type-aware highlighting:

现在你按下这个图标,你可以在任何地方禁用它,你的错误就会消失,但这意味着你会在任何地方丢失类型验证.

Now you pressing on this icon you can disable it everywhere and your error will be gone, but that means that you'll lose your type validation everywhere.

没有那么激进的方法.根据 IntelliJ 文档,将您的代码包含在 /*_*/.../*_*/,允许在本地禁用类型感知突出显示.

There is less radical approach. According to IntelliJ documentation, enclosing your code in /*_*/ ... /*_*/, allows to disable type-aware highlighting locally.

例如:

class Test {
}

class Test1 {
  /*_*/
  override def foo = 1
  /*_*/
}

在这种情况下,override def foo 将不会突出显示.

In this case, override def foo will not be highlighted.