简体   繁体   English

如何折叠所有变量以提高代码可读性?

[英]How to fold away all variables to improve code readabillity?

In some my code i have a lot of variables.在我的一些代码中,我有很多变量。 So to make it more readable i want to be able to fold them away so instead of this:因此,为了使其更具可读性,我希望能够将它们折叠起来,而不是这样:

public class BIhcsAhuStartSeq_v2 {
    int counterVal_1 =0;
    int counterVal_2 =0;
    String clear="";
    String reset= "reset";

    public void test(){
        if(counterVal_1==1){setString(clear)}
    }
}

I want to do something like the below example so i can fold all variables away.我想做类似下面例子的事情,所以我可以折叠所有变量。 How can i do this?我怎样才能做到这一点?

public class BIhcsAhuStartSeq_v2 {

    { 
    int counterVal_1 =0;
    int counterVal_2 =0;
    String clear="";
    String reset= "reset";
    }

    //example, but i cant acces the variables in the constructor ?
    public void test(){
        if(counterVal_1==1){setString(clear)}
    }
}

This has been asked several times here, on Stack Overflow.这已经在 Stack Overflow 上被问过好几次了。

Basically, the folding function implementation varies by IDE.基本上,折叠 function 实现因 IDE 而异。 For Eclipse, there was the Coffee-Bytes plugin to do custom (tagged), fold-able code blocks, but that has been abandoned.对于 Eclipse,有 Coffee-Bytes 插件来执行自定义(标记)、可折叠代码块,但已被放弃。

https://code.google.com/archive/p/coffee-bytes/ https://code.google.com/archive/p/coffee-bytes/

Other mentions have been to use Jet Brains IDEA其他提到的是使用 Jet Brains IDEA

https://blog.jetbrains.com/idea/2012/03/custom-code-folding-regions-in-intellij-idea-111/ https://blog.jetbrains.com/idea/2012/03/custom-code-folding-regions-in-intellij-idea-111/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM