以编程方式格式化和缩进从 Java 自动生成的源代码
我编写了代码生成器,它使用 Antlr 从自定义 IDL 创建 Java 和 C++ 源代码。除了 Java 代码格式之外,它工作得很好。目前我使用 Gnu Indent,但它输出的格式几乎难以阅读,并且使调试变得很痛苦。我希望使用与 NetBeans 相同的代码格式化程序(例如按 Alt+Shift+F 时)来格式化生成的文件。我不想浏览每个文件并手动按 Alt+Shift+F。我尝试使用 NetBeans API,但要么我没有在正确的位置查找,要么 Google 是个白痴,我找不到合适的工作示例来对编辑器中未加载的文件执行此操作...
有人至少可以指导我吗朝着正确的方向前进?
I wrote code generator that creates Java and C++ source code from custom IDL using Antlr. It works perfectly except for the Java code formatting. Currently I use Gnu Indent, but the format that it spits out is hardly readable and makes debugging a pain. I would love to use the same code formatter as NetBeans does (like when you press Alt+Shift+F) to format the generated files. What I do not want is to go through each of these files and manually pressing Alt+Shift+F. I tried using the NetBeans API, but either I am not looking in the right places or Google is being an idiot, I cannot find a proper working example to do this on files not loaded in the editor...
Can someone at least guide me towards the right direction for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下插件 http://plugins.netbeans.org/plugin/18365/format -文件
You could use the following plugin http://plugins.netbeans.org/plugin/18365/format-files
Jalopy
Jalopy