It should be pretty easy to do this with JavaCC.  Just use one of the
Java grammars that are included with JavaCC and write the parse tree
back out in whatever order you need.  This will make it possible to
preserve javadoc too.  You didn't mention where Visual Age puts field
declarations, but JavaCC should be able to help there too.

You might also want to search the comp.compilers.tools.javacc newsgroup
to see if anyone has already done something similar --> it seems like
the sort of "code beautifying" tool that a compulsive neat freak 
must have been inspired to write at some point.

You could also look at ANTLR for the same stuff: it's a different
parser generator, and its adherents may have done something that would
be helpful to you.

Eric


In message <[EMAIL PROTECTED]>, "Perkens-Golomb, Burkhard" writes:
: I'm looking for a tool to arrange methods in Java sources
: alphabetically.
: 
: I've given away sources to a customer. They've worked with them in
: Visual Age and I want to look at their changes. They don't remember
: all changes they've made so I have to do a diff. But Visual Age stores
: the sources in a database, not in flat files, and if you want normal
: Java files from Visual Age you get them terrible formatted and the
: methods are arranged alphabetically. A diff with my sources is futile.
: 
: I'm looking for a tool to arrange the methods in my sources
: alphabetically.  Of course I could load my sources in Visual Age and
: get them back terrible formatted, too :-) . But I don't have Visual
: Age and I don't want to use it if it's possible without it!
: 
: Could Emacs do it (with semantic, senator etc.)? Or other tools? Any
: ideas or hints?
: 
: TIA,
: 
:         Burkhard
: 

Reply via email to