[英]Suppress the “unused” warning for a method, but not the variables within it
As the title asks, how do I suppress the warning for just the method? 正如标题所示,我如何抑制该方法的警告? Is this possible?
这可能吗?
A little background: I'm using a JavaScript bridge and it hooks into these methods, so I'd like to suppress this warning. 一点背景:我正在使用JavaScript桥接器并且它挂钩到这些方法,所以我想抑制这个警告。 What I would like to avoid is the annotation preventing warnings for unused variables within the method.
我想避免的是注释防止方法中未使用的变量的警告。 I'm currently just using the
@SuppressWarnings("unused")
before the method declaration, but this suppresses everything. 我目前只是在方法声明之前使用
@SuppressWarnings("unused")
,但这会抑制一切。
As far as I know, there is no way to scope SurpressWarning to the method declaration only. 据我所知,没有办法将SurpressWarning的范围仅限于方法声明。
This leaves you with these possibilities: 这将为您提供以下可能性:
In eclipse, If we set the following 在eclipse中,如果我们设置以下内容
Preferences -> Java -> Error/Warnings -> Unnecessary code -> Local variable is never read ==> Error
首选项 - > Java - >错误/警告 - >不必要的代码 - >永远不会读取局部变量==>错误
then, even when the @SuppressWarnings("unused") is applied on the method it only suppresses unused method warning. 那么,即使在方法上应用了@SuppressWarnings(“unused”),它也只会抑制未使用的方法警告。 The unused variable is shown as an Error.
未使用的变量显示为错误。
(I know, you wanted them to be 'warnings' but all I can come up with are 'errors' !) (我知道,你希望他们成为'警告',但我能想到的只是'错误'!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.