Synergy Java code format utility ================================ Version 0.9 Code format and arrangement Author: John Newbigin Copyright Synergy Software Use this software at your own risk etc..... Usage: style file1 file2 dir1 dir2 ... Will descend a source directory tree and reformat java source files. You can specify as many files and directories as you want. Only .java files are formatted, even if you specify the name on the command line This program is designed to be used only on valid java source code. If the code does not compile, then chances are this format utility will fail. This is a list of sorts of the functionality of the program - Fix indentation: no tabs, 4 space indents - Fix brace locations: on new lines, not indented - Fix block comment style: indented? - Fix single line comments??? - File line feeds (13, 10) ? - Add missing braces around single line if's and while's Backups ======= all files change are backed up to file.java.~n where is n is the smallest integer greater than or equal to 0 for which a files does not exist. Whitespace ========== By default, whitespace is applied between every token. This can be too much whitespace, even for the most compulsive programmer. eg: import java . lang . String ; To overcome this, there are a set of rules for when not to apply whitespace. These are quite flexible and open to comment if you think there needs modification. NewLines ======== Either dos or unix newlines are supported. It also handles missing #10's in dos newlines. The output is unix newlines only. If your editor does not support this, then get a better editor. Future versions will add the option for dos/unix newlines. Braces ====== Are placed on separate lines Indentation is based on the braces. 4 space indents Missing braces are added, but the style program will need to be run again to correct the formatting. Comments ======== Javadoc comments are formatted to look like /** * This :) */ @tags are checked for each class, method and instance variable. The required tags are also open to comment. Currently the requirements are The Main Class requires @author @rref @copyright @concurrency @see Method requires @param @returns @throws @pre @post Instance Variables none Inner classes none Missing @tags are added, but not into an existing comment block. If these are added, a comment is also written to the screen. If the file does not contain a // $Header comment it will be added Class order =========== 1 class per file (NYI) name must match file name (NYI) The file is arranged to match the following order. This can effect the location of blank lines. If the code is in order, newlines will not be effected. Follow order Variables public protected default private Constructors public protected default private Methods public constructors get+set, in matching pairs get with no set set with no get do is on add+remove in matching pairs add with no remove remove with no add others in original order protected constructors get+set, in matching pairs get with no set set with no get do is on add+remove in matching pairs add with no remove remove with no add others in original order default constructors get+set, in matching pairs get with no set set with no get do is on add+remove in matching pairs add with no remove remove with no add others in original order private constructors get+set, in matching pairs get with no set set with no get do is on add+remove in matching pairs add with no remove remove with no add others in original order Inner classes NYI === These are suggested ideas which might get implemented. Variables only one per line Generate dependency files: based on import commands. Find any import *'s Constants Start with a 'k' Literals No string Literals No numeric literals, except 0 and 1 Classes start with B Packages packages start with au.edu.swin.synergy....? no import ....*; NOTE ==== The source code to this utility will be made available once the team project is complete. Changes ======= Version 0.8 Correctly handles <<, <<<, <<<=, >>, >>>, >>>= numbers followed by a 'L' Version 0.9 Removed spaces around ++, -- and function( Detects iv's with a set of initial data as iv's, not methods