java 如何在 VS Code 中禁用错误​​突出显示?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46061857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 09:01:57  来源:igfitidea点击:

How to disable error highlighting in VS Code?

javagroovyvisual-studio-code

提问by J?rg Rech

I need to disable error highlighting in Java files in VS Code. VS Code tries to check a Groovy file while thinking it is a Java file.

我需要在 VS Code 中禁用 Java 文件中的错误突出显示。VS Code 尝试检查 Groovy 文件,同时认为它是 Java 文件。

As you can see in the picture all imports after the first and the types after the first field are highlighted red (due to missing semicolons). However I do not want the error check for this Groovy file. enter image description here

正如您在图片中看到的那样,第一个字段之后的所有导入和第一个字段之后的类型都以红色突出显示(由于缺少分号)。但是我不想要这个 Groovy 文件的错误检查。 在此处输入图片说明

NOTE: I only have the plugins Clang, RedHat.Java, Markdown PDF, Sort Lines, and Uncrustify installed. Even if I disable all the red highlighting is visible.

注意:我只安装了 Clang、RedHat.Java、Markdown PDF、Sort Lines 和 Uncrustify 插件。即使我禁用所有红色突出显示也是可见的。

回答by John Henckel

open your preferences file and add this

打开您的首选项文件并添加此

"java.validate.enable": false

I didn't try it for java, but it works for typescript.

我没有为 java 尝试过,但它适用于打字稿。

回答by Anacarde

I found this:

我找到了这个:

"problems.decorations.enabled": false,

回答by Ajinkya Dhote

You should disable the linter, which is by default enable in VS Code. To do so you can go to File-> Prefrences -> setting

您应该禁用 linter,这是在 VS Code 中默认启用的。为此,您可以转到文件-> 首选项-> 设置

回答by Mark

I wouldn't think this is necessary but you might try:

我不认为这是必要的,但您可以尝试:

"files.associations": {
   ".groovy": "groovy"
}

in your user settings, assuming your file extension is .groovy. If it is something else, just set it to "groovy" as well. When I create a .groovy file with your content or gibberish I get no error linting at all. What is your file extension and what does Vscode call it in the bottom right of the editor? You can click on that file type to change its file associations. See modifying Vscode file extensions.

在您的用户设置中,假设您的文件扩展名是 .groovy。如果它是别的东西,只需将其设置为“groovy”。当我使用您的内容或胡言乱语创建 .groovy 文件时,我根本没有发现任何错误。你的文件扩展名是什么,Vscode 在编辑器的右下角叫它什么?您可以单击该文件类型以更改其文件关联。请参阅修改 Vscode 文件扩展名