IntelliJ删除所有使用的方法吗? [英] IntelliJ remove all uses of a method?

查看:74
本文介绍了IntelliJ删除所有使用的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ提供有用的功能来查看方法的所有用法,并在删除之前检查用法.

IntelliJ gives useful functionality to see all usages of a method, and to check for usages before delete.

是否有一种方法可以删除方法的所有用法?

Is there a way to delete all usages of a method?

推荐答案

可以,但是并不安全.如果确实确定要删除所有用法,则可以:

Yes you can, but it is not safe. If you are really sure that you want to delete all usages, then you can:

  • 手动清空方法主体
  • 内联该方法,并使其删除所有调用 Ctrl + Alt + N
  • Empty the method body manually
  • Inline the method and let it remove all invocations Ctrl+Alt+N

您可能会严重破坏源代码.安全删除 Alt + Del 是更好的解决方案,即遍历调用并手动删除它们.

You could seriously break the source code. Safe-deleting Alt+Del is the better solution, that is, iterating through the invocations and deleting them manually.

即使您清空&内联该方法,请确保您首先仔细检查调用.

Even if you empty & inline the method, make sure you first double-check the invocations.


示例-内联之前:


内联结果:

这篇关于IntelliJ删除所有使用的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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