java - IntelliJ - 在包含许多方法的类中查看*单个*方法

标签 java intellij-idea

有没有办法在 IntelliJ IDEA 编辑器中只查看类的一个方法并隐藏其他所有内容,和/或在该 View 和常规 View 之间切换。

请注意,我希望折叠/折叠其他方法,这当然是一种尽量减少在大文件中迷失方向的方法。 我正在寻找一种方法来仅查看我在类中处理的特定方法。

e.g. If there is a legacy code where an existing class has 10 long methods (each ~50 lines long), and I'm working on one of them and don't wish to be lost in the 500 lines of code and need to focus on a single method thereby narrowing my view to 50 lines of code.

我确实记得以前的几个版本说这是可能的,但我现在找不到那个设置。

进一步澄清我的问题。考虑下图中选择的方法 all other methods collapsed

我对仅显示如下方法的 View 感兴趣(当然启用了所有 Java 功能,如代码突出显示、重构等): just one method shown

最佳答案

在 IntelliJ IDEA 2019.3.3(社区版)中,有一个折叠选项“折叠选择”,甚至可以隐藏签名。

  1. 选择/突出显示您要关注的方法上方的代码
  2. 右键单击 > 折叠 > 折叠选择。快捷键 = cmd + .

它可能在早期版本中,但我没有检查过。

Fold selection menu option

关于java - IntelliJ - 在包含许多方法的类中查看*单个*方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53999259/

相关文章:

java - 没有 bean 有资格作为此依赖项的 Autowiring 候选者

java - 使用 Eclipse 调试 xslt 时出现 JVM 错误

spring - 此处不允许注释

Java:如何将类移动到 Idea Intellij 中的另一个包?

java - 有用的 Intellij 实时模板

intellij-idea - gradle 在 Intellij 中不起作用 - JAVA_HOME 问题

java - 警告 : Unclosed files for the types '[io.realm.OrderListRealmProxy]' ; these types will not undergo annotation processing

java - Linux 领域的 "Unable to access jarfile"

java - 如何计算 Web 服务器中 Web 容器线程的最大和最小数量,例如 Tomcat ,是

android - 将 AS 项目迁移到 IDEA 时,无法将 com.android.build.gradle.internal.model.ApiVersionImpl 转换为 java.lang.Integer