Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically format and indent automatically generated source from Java

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?

like image 493
NeoAcheron Avatar asked Mar 08 '11 10:03

NeoAcheron


2 Answers

You could use the following plugin http://plugins.netbeans.org/plugin/18365/format-files

like image 162
Ben Avatar answered Oct 31 '22 00:10

Ben


Jalopy

like image 31
Harsha Hulageri Avatar answered Oct 30 '22 23:10

Harsha Hulageri