告诉IntelliJ IDEA的哪些方法不识别为未使用 [英] Telling IntelliJ IDEA which methods not to identify as unused

查看:3927
本文介绍了告诉IntelliJ IDEA的哪些方法不识别为未使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ IDEA的有一个方便的功能可以检测未使用的方法,并显示在灰色,暗示死code潜在的警告。

IntelliJ IDEA has a handy feature to detect unused methods and show them in grey, hinting a potential warning for dead code.

的一些方法,但是,不是直接而是通过反射执行。一个很好的例子是这是由Spring执行 @RequestMapping -annotated方法。的IntelliJ有着不俗的Spring集成,因此它检测到这个注解,并且不标注这样的方法为未使用。

Some methods, however, are not executed directly but via reflection. A good example would be @RequestMapping-annotated methods which are executed by Spring. IntelliJ has decent Spring integration hence it detects this annotation and does not mark such a method as unused.

我有一个微小的AJAX框架,我用我自己的注解来点,可以执行基于某些HTTP请求属性哪种方法(非常相似, @RequestMapping 正在做) 。可以理解的是,的IntelliJ不知道是什么做我的注释代表和和标志,如不使用的一种方法,增加不必要的噪音。

I have a tiny AJAX framework where I use my own annotation to point which method to execute based on certain HTTP request properties (very similar to what @RequestMapping is doing). Understandably, IntelliJ has no idea what does my annotation stand for and and marks such a method as unused, adding unnecessary noise.

我想的是:


  • 注释标注我与另一个注解,但是否有任何标准的人,会做这项工作没有任何额外的努力?

  • 中找到的IntelliJ特定设置,以确定自定义注解为所使用的标记方法,但这需要其他队员做同样的,基本上是一种痛苦。

任何人都可以提出任何想法如何解决这个问题?

Can anyone suggest any ideas how to solve this problem?

推荐答案

您可以告诉的IntelliJ给不给警告用于与标注的未使用的方法有注解的任何方法/场。

You can tell IntelliJ to not to warn about used for any method/field annotated with the annotation the "unused" method has.

这应该是一个速战速决所有你所要做的就是打< ALT> +<输入>,然后选择燮preSS由...

It should be a quick fix all you have to do is hit <Alt>+<Enter> and select Suppress for methods annotated by ...

您不需要添加任何东西给你code和你只需要每注解做一次。

You don't need to add anything to you code and you only have to do this once per annotation.

这篇关于告诉IntelliJ IDEA的哪些方法不识别为未使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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