netbeans中的代码清理 [英] Code cleanup in netbeans
问题描述
你也可以做一整套类/包而不是单个类吗?
重构> Inspect and Transform
Inspect and Transform
是否有类似于
的Eclipse清理规则((Preferences>
Java >
NetBeans?>
在NetBeans 8.0中,强大的批处理工具是重构
> 检查和转换
。参见教程页面在NetBeans IDE Java编辑器中使用检查和转换进行重构。
个别工具也可用: 修复导入
对于单个文件,命名空间或项目(取决于在项目窗口中选择的项目还是具有焦点):Source> Organize Imports(对未使用的导入进行排序和删除)或Source> Fix Imports(要进行排序,删除未使用的导入,并添加缺少的导入)。或在每次保存期间:工具>选项>编辑器>在保存>组织导入。 删除尾部空格
对于单个文件(将carret放在代码文件中):Source> Remove Trailing Spaces。或在每次保存期间:工具>选项>编辑器>在保存>删除尾随空白。 单个文件,名称空间或项目:Source> Format。 (自定义工具>编辑器>格式化
中的规则)。还有一个叫Jindent的插件可以安装(我自己也没用过)。或者在每次保存时:工具>选项>编辑器>在保存>重新格式化
。
默认情况下,Netbeans会在有问题的代码行旁显示提示图标并在滚动条中,允许您执行自动修复,如果需要的话。这些可以通过 Tools>来配置。选项>编辑器>提示
。 Netbeans可以使用Source> Inspect来搜索项目中的所有问题。或者,要重申的是,许多这些问题可以用 Refactor>批量修复。检查和转换
。
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?
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 inTools > 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
.
这篇关于netbeans中的代码清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!