IDEA显示正在使用的方法,而不是 [英] IDEA shows method as in use, when it is not

查看:371
本文介绍了IDEA显示正在使用的方法,而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么IDEA会在使用中显示此 SimpleClass.start 方法:

Why does IDEA show this SimpleClass.start method as in use:

即使不是。将方法的名称更改为其他内容然后将其显示为未使用:

Even when it is not. Changing the name of the method to something else then greys it out as not in use:

似乎不仅发生在 start ,还包括 init 停止我尝试过的。我在Windows上使用的是版本13.1.4。

Seems to not only happen with start but also init and stop for ones I've tried. Am using version 13.1.4 on Windows.

推荐答案

这是一项性能优化。


  • 基本上IntelliJ IDEA 首先 检查其索引是否出现该方法的名称

  • 然后检查每次出现的文件,看看它是否真的是该方法的用法。

  • 如果方法的 名称 用于 多个地方 ,必须解析和检查许多文件。要 避免 花费太多时间 和cpu,如果有超过一定的数量,则会跳过检查索引中出现的次数 假定 该方法 使用 (因为概率非常高) 。

  • 以批处理模式运行 未使用的声明 检查(分析>按名称运行检查... )仍然会将该方法报告为 unused

  • Basically IntelliJ IDEA first checks its index for occurrences of the name of the method.
  • Then it checks in the file of every occurrence to see if it's really a usage of that method.
  • If the name of the method is used in many places, many files will have to be parsed and checked. To avoid taking too much time and cpu for that, the check is skipped if there are more than a certain amount of occurrences in the index and it assumes that the method is used (Since the probability is very high).
  • Running the unused declaration inspection in batch mode (Analyze > Run Inspection by Name...) will still report the method as unused.

这篇关于IDEA显示正在使用的方法,而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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