Code Style

Robert Fraser fraserofthenight at gmail.com
Sun Jun 17 19:05:49 PDT 2007


Hi, all! Thanks for your help. It looks like there's about 2 or 3 coding styles that seem pretty popular, so I'll make a pofile for each o start with, and you can customize it down to the smallest detail if you feel the need.

I can make it possible to execute the formatter from the command line. However, it relies on other parts of the plugin, so I can't really make it completly independent: you'll probably have to download JDK 1.5+, Eclipse, and Descent and set up the options in the UI (unless you're feeling the desire to edit a huge text file...)

The formatter itself prints everything token-by-token, so it'll only be able to change around white space (and yes, it'll be able to change between spaces & tabs). However, after the formatter is done, I'm going to work on a "code clean-up" engine similar to the one in the eclipse JDT that can remove or add curlies for single-line statements, add "in"/"const"/"final" wherever it can, etc., etc... This requires a few other parts of the plugin, though, so it might be a bit longer. Sorting members (either by type or alphabetically), is pretty easy, though, so that might be the next project.

If you're interested, grab the SVN version of Descent; the formatter works (on most code... it might throw a wierd exception once in a while; but I got it working on all of Tango 0.98), so you can let it shred away at your code as long as your code complies with DMD 1.007 (i.e. "inout" instead of "ref", no AA literals (struct literals are OK, but they'll be mormatted as function calls most liely), etc., etc.). It will pobably make it look worse, not better (esp. switch case blocks; they still need some work), and the only part configurable as of yet is the braces. There's no command-line version yet.

Thanks for all your help,
Fraser



More information about the Digitalmars-d mailing list