简体   繁体   中英

How to fold or hide setters and getters in Eclipse?

The problem is that there're too much setters and getters messing up the source code editor.

I have to scroll up and down and distinguish where are the demarcation of the business methods.

Is there a plugin that I can hide or fold setters and getters?

I know there're some libraries can eliminate setters and getters by using annotations or AOP techniques, but this is not allowed in my project.

我宁愿将业务方法放在 setter和getter 之上 ,并在它们之间放置这样的东西:

//================== Setters and getters start =====================

Use Ctrl + O to navigate

Create section that separate specific part of code (like Bozho suggested).

Instead of scrolling the code You can use the outline view.

While You are working with Eclipse the mouse is not really needed.

Coffee Bytes Code Folding is your friend:

Adds Code Folding preference page - Enable/Disable folding types - Control Folds: eg getter/setter, main methods, constructors, other methods separately. - Fold Javadocs, Block Comments, etc. separately - Filter foldable regions (eg on number of lines) - Define own foldable regions based on specially defined comments and define custom folding structures (eg if, while, try/catch, switch, comments, ...) - New icon set

如果你有太多的getter和setter使你对业务方法感到困惑,那么现在是时候重构成两个独立的类了。

Checkout projectlombok . It will generate getters/setters for your properties automatically and keeps your source clean of this boilerplate code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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