Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there something similar to the Eclipse cleanup rules (Preferences > Java > Code Style > Clean Up) in NetBeans?

The cleanup rules in eclipse will allow you to clean things up like organizing imports, removing unnecessary casts, adding missing override annotations etc.

Also can you do that on a whole set of classes/packages instead of individual classes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
127 views
Welcome To Ask or Share your Answers For Others

1 Answer

Refactor > Inspect and Transform

Is there something similar to the Eclipse cleanup rules ((Preferences > Java > Code Style > Clean Up) in NetBeans?

In NetBeans 8.0, the powerful batch tool is Refactor > Inspect and Transform. See the tutorial page, Refactoring with Inspect and Transform in the NetBeans IDE Java Editor.

Individual tools are also available:

  • Fixing imports
    For a single file, namespace, or project (depending on what's selected in Project window or has the focus): Source > Organize Imports (to sort and remove unused imports) or Source > Fix Imports (to sort, remove unused imports, and add missing imports). Or during every save: Tools > Options > Editor > On Save > Organize Imports.

  • Removal of trailing spaces
    For a single file (place the carret in the code file): Source > Remove Trailing Spaces. Or during every save: Tools > Options > Editor > On Save > Remove Trailing Whitespace.

  • Code Format
    For a single file, namespace, or project: Source > Format. (Customize the rules in Tools > Editor > Formatting). There is also a plugin called Jindent you can install (I have not used it myself). Or during every save: Tools > Options > Editor > On Save > Reformat.

By default, Netbeans will display hint icons next to problematic lines of code and in the scrollbar, allowing you to perform an automatic fix if desired. These can be configured via Tools > Options > Editor > Hints. Netbeans can search all problems in the project using Source > Inspect. Or, to reiterate, many of these problems can be batch fixed with Refactor > Inspect and Transform.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...