Java:@SuppressWarnings(...)参数的完整列表(在Netbeans中)? [英] Java: complete list of @SuppressWarnings(...) parameters (in Netbeans)?

查看:156
本文介绍了Java:@SuppressWarnings(...)参数的完整列表(在Netbeans中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Netbeans提供了很多自定义提示,就像警告一样,只是大多数都无法被抑制(只是全局禁用IDE)。

Netbeans provides a lot of custom "hints", which are like warnings, only that most of them can't be suppressed (just disabled IDE-globally).

但现在我查看使用的代码

But now I looking at code which uses

@SuppressWarnings("element-type-mismatch")

来抑制名为可疑方法调用的提示/警告(例如删除(...)用于错误类型的集合。

to suppress a hint/warning which is called "suspicious method call" (such as remove(...) for a collection with a "wrong" type).

好吧,我永远不会来想要使用名为元素类型不匹配的 SuppressWarnings - 参数来抑制名为可疑方法调用的提示,但显然,它可以正常工作。

Well, I would never come to the idea to suppress a hint named "suspicious method call" with a SuppressWarnings-parameter called "element-type-mismatch", but apparently, it works.

那么,是否有这些参数的魔术列表?

例如,如何做我禁止提示/警告返回收集字段?

How, for instance, do I suppress the hint/warning "return of collection field"?

注意:对于 THI类似的问题,元素类型不匹配未列出

NOTE: for this similar question, "element-type-mismatch" is not listed.

推荐答案

简要介绍一下NB-sourcecode,我在一些java.hint -classes中找到了这些:

After a brief look at the NB-sourcecode, I found these in some of the java.hint -classes:

@Hint(category="bitwise_operations", suppressWarnings="IncompatibleBitwiseMaskOperation")
@Hint(category="initialization", suppressWarnings="LeakingThisInConstructor")
@Hint(category="logging", suppressWarnings={"NonConstantLogger"}) //NOI18N
@Hint(category="logging", suppressWarnings={"ClassWithMultipleLoggers"}) //NOI18N
@Hint(category="logging", suppressWarnings={"ClassWithoutLogger"}, enabled=false) //NOI18N
@Hint(category="code_maturity", suppressWarnings="UseOfObsoleteCollectionType")
@Hint(category="initialization", suppressWarnings="OverridableMethodCallInConstructor")
@Hint(category="bitwise_operations", suppressWarnings="PointlessBitwiseExpression")
@Hint(category="code_maturity", suppressWarnings="CallToThreadDumpStack")
@Hint(category="bitwise_operations", suppressWarnings="ShiftOutOfRange")
@Hint(category="initialization", suppressWarnings="StaticNonFinalUsedInInitialization")
@Hint(category="code_maturity", enabled = false, suppressWarnings="UseOfSystemOutOrSystemErr")
@Hint(category="code_maturity", suppressWarnings="CallToPrintStackTrace")

显然,并非所有显示为警告的IDE提示都是可抑制的...
不知道为什么会这样,因为很多人都使用了AbstractHint类很容易扩展提供这种能力...
这些只是抑制名称,所以要找到它们所代表的警告名称的映射,需要在源代码中进行更深入的挖掘。

Apparently, not all IDE-hints that are displayed as warnings are made suppressable... Don't know why though, 'cause the AbstractHint class wich many of them extends easily provides this ability... These are just the suppress-names though, so to find the mapping to the names of the warnings they represent, a deeper dig in the source is needed.

这篇关于Java:@SuppressWarnings(...)参数的完整列表(在Netbeans中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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