User Manual
- User Manual
- 1. How To Use FixStyle
- 2.0 Options
- 2.1 Array Type Style
- 2.2 Inline Conditionals
- 2.3 Curly Braces
- 2.4 Line Length
- 2.5 Method Parameter Pad
- 2.6 Single Line Braces
- 2.7 Paren Pad
- 2.8 Tab To Spaces
- 2.9 Whitespace Around
- 2.10 Newline At End Of File
- 2.11 Enforce Javadocs
- 2.12 Set Indent Width
- 2.13 Array Trailing Comma
- 2.14 Default Comes Last
- 3.0 Features of FixStyle
- 4.0 Other Jalopy Features Available
User Manual for FixStyle
April 28, 2008
CPE 309-01
1. How To Use FixStyle
1.1 Style Options
Description
FixStyle comes with different style options for the user to choose from. FixStyle defaults to the Sun Java Standard (see Fixstyle Profiles) if the user leaves the options unchanged. To see the list of options, click here.
1.2 Set FixStyle Preferences
There are two ways to set the preferences. The first way is to select the Tools Menu and click "FixStyle Preferences". The other way is to select the Tools Menu and click Preferences... Then click the Extensions tab in the BlueJ Preference window. Finally click the Edit Style Conventions button in the Fixstyle box.
From there each of the options offered by FixStyle can be found in the subdirectories.
1.3 Run FixStyle
Right click on the file needing to be formated. Select "FixStyle" and Click "Format".
Note: This will only work on compiled code. This option will be disabled if the file is not compiled. Also note that clicking undo in the class Editor will only cause the code to register as uncompiled. To undo the format, see Undo in Fixstyle below.
1.4 Undo in FixStyle
Description
After using FixStyle to format a file, it is possible to undo the formatting that was just done if the changes were not what the user wanted.
How To Use This Feature
Right click on the file that was just formatted. Select "FixStyle" and Click "Undo".
Note: This will work on any file that was formatted with Fixstyle at any time. Also, Undo will only return the file to its state before the latest format was clicked. This means that if format is clicked twice, the last state of the code is formatted so that is what Undo will revert to. If format is only clicked once, it will return the code to what it once was. Also, after clicking Undo, the option will be disabled because there is nothing more for Fixstyle to undo until format is clicked on the file again. The undo in the class Editor works just like in the Format option, it will only cause the code to register as uncompiled but the text will not change. Lastly, clicking the Undo option from Fixstyle will not cause the code to become uncompiled. Since the code before the format was compiled, clicking Undo will cause that previous version that is compiled to come back.
1.5 FixStyle Profiles
Description
The user may save FixStyle configurations as profiles and load for quick use to change back any modified settings. Users may create a new profile, save over an existing profile, load a saved profile, or delete an unwanted profile.
How To Use Access This Feature
Access the FixtStyle preference pane by using the procedure in section 1.2.
Initial Default Profile
Without changing any options in the FixStyle options menu the extension will be set to standard Sun Java Standard profile. If the desire is to change to a pre-defined convention, go to the General label in the Jalopy settings box, select the desired default from the combo box in pre-defined conventions, click use, and then ok at the bottom of the panel.
Create A New Profile
Go to the General label in the Jalopy settings box, type in a new name and description for this convention, click apply, click export, click browse on the box that pops up, and finally name and place the profile in a folder of your choosing. Click ok on that menu to save the profile.
Creating a New Profile from An Existing Profile
Click the General label in the Jalopy settings box. Click import, click browse in the box that pops up, locate the profile, click ok in that box to load that profile. Then type in a new name and description for this convention. Then click export, click browse on the box that pops up, and finally name and place the profile in a folder of your choosing. Click ok on that menu to save the profile.
Editing An Existing Profile
Click the General label in the Jalopy settings box. Click import, click browse in the box that pops up, locate the profile, click ok in that box to load that profile. Change the desired settings and click ok on the Jalopy settings panel.
Load A Profile
Click the General label in the Jalopy settings box. Click import, click browse in the box that pops up, locate the profile, click ok in that box to load that profile. Then click ok on the Jalopy setting panel.
1.6 Default Conventions
In addition to creating and saving conventions, Fixstyle will come with several coding style defaults for the user to chose from. These defaults can be loaded from the General Settings page in the Jalopy Settings window.
Loading a default
To load a default, click the drop down menu within the "Default Conventions" box on the general settings page. Select a convention from the list. Click the button labeled "Use" next to the drop down menu. All of the convention settings should be set to the defaults for the selected convention.
Default Summary
Fixstyle will come with these conventions as defaults for the user to chose:
- Sun Java Standard
- GNU Standard
- Ansi C Standard
Each of these conventions will contain the following settings:
| Setting | Sun | GNU | Ansi |
| Braces-General-Styles | Sun Java Style | GNU Style | C Style |
| Braces-Misc-Insert braces-if...else | On | Off | Off |
| White Space-Space before-Method declaration parentheses | Off | On | Off |
| ..Method call parentheses | Off | On | Off |
| ..Statement parentheses | On | On | On |
| White Space-Space after-Comma | On | On | On |
| ..Semicolon | On | On | On |
| ..Type cast | On | On | On |
| ..Negation | Off | On | Off |
| White Space-Space around-... Assignement Operators Bitwise operators Logical operators Mathematical operators Relational operators Shift operators | On | On | On |
All other jalopy settings are either disabled or at the jalopy default setting.
Modify or add defaults
The user can make changes to the defaults that come with Fixstyle and even add a new default which will appear in the drop down menu along with the existing standard conventions.
Add a convention
Create a new profile according to the Fixstyle Profiles section of this user manual. Save that profile in a folder named "Fixstyle" in the user's home directory. If the user has already run Fixstyle once, this folder should already exist and contain the 3 default xml files (sun.xml, gnu.xml and ansi.xml). Copy the desired convention xml file into this folder and it will be listed in the default conventions drop down menu the next time the general settings page is viewed.
Modify a default
Load the default convention you wish to modify. Make any desired changes to the convention and click export. Just like with adding a convention, save it to the directory named "Fixstyle" under the user's home directory. To submit the changes, name the file the same as the default which was loaded earlier.
Reset all conventions
To reset all the default conventions and remove any added conventions, simply delete the directory named "Fixstyle" under the user's home directory. Fixstyle will re-create this directory and load it with the original defaults the next time the general settings page is viewed.
1.7 Preview Pane
Every setting option in Fixstyle settings panel changes the preview pane to show the expected output of the option.
2.0 Options
2.1 Array Type Style
Description
This feature checks a source code file to see if array declaration follows either the Java standard or the C style standard. If an array is declared using a style other than the one specified by the user, FixStyle changes it to the desired format.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Misc". (4.) In the corresponding panel that appears on the right side of the window click or unclick the "Array Brackets after identifier" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: Changing To Java Style
Before:
int a[];Ok.
After:
int[] a;
2.2 Inline Conditionals
Description
This feature checks a source code file for any inline conditionals. If FixStyle finds any it replaces them with an if-else statement, maintaining the same logic and making the code easier to read.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Misc". (4.) In the corresponding panel that appears on the right side of the window click "Remove Inline Conditionals" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
String b= (a==null || a.length<1) ? null : a.substring(1));
After:
String b;
if (a==null || a.length<1)
{
b=null;
}
else
{
b=a.substring(1);
}
2.3 Curly Braces
Description
This feature checks a source code file to see if the curly brace positions meet the style for the situation set by the user. The user may specify where to place the left curly brace with one of the following:
- C style
Left curly under statement declaration and right curly on its own line.
- GNU style
Left curly under statement declaration and indented 2 extra spaces and right curly on its own line.
- Sun Java style
Left curly on same line as statement declaration and right curly on its own line (except with do-while loops).
- Custom style
With each of these options, the user may specify two special cases:
- Treat class/method blocks different
- Treat class/method blocks different if wrapped
Also under Custom style, the user may choose between the following:
- Newline before left brace
- Newline after right brace
Along with choosing whether or not to use the new lines, Custom style allows the user to state how much white space to use in these situations:
- Before left brace
- Before right brace
- After right brace
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Braces". (4.) In the corresponding panel that appears on the right side of the window, click the check box next to the desired style. (5.) Under wrapping, choose options you wish !Fixstyle to implement. (6.) Set the white space as needed. (7.) Click Ok. (8.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: C style
Before:
public class Aclass {
public void method(int x, int y){
}
}
After:
public class Aclass
{
public void method(int x, int y)
{
}
}
Example: GNU style
Before:
public class Aclass {
public void method(int x, int y){
}
}
After:
public class Aclass
{
public void method(int x, int y)
{
}
}
Example: Sun Java style
Before:
public class Aclass
{
public void method(int x, int y)
{
}
}
After:
public class Aclass {
public void method(int x, int y) {
}
}
Example: Newline before left brace
Before:
if(a==b){ a= b+3; }
else{ b++; }
After:
if(a==b)
{ a= b+3; }
else
{ b++; }
Example: Newline after right brace
Before:
if(a==b){ a= b+3; }else{ b++; }
After:
if(a==b){ a= b+3; }
else{ b++; }
Example: Treat class/method blocks different without newline before left brace
Before:
public class Aclass {
public void method(int a,
int b){
if(a==b){ a= b+3; }
else{ b++; }
}
}
After:
public class Aclass
{
public void method(int a,
int b)
{
if(a==b){ a= b+3; }
else{ b++; }
}
}
Example: Treat class/method blocks different if wrapped without newline before left brace
Before:
public class Aclass {
public void method(int a,
int b){
if(a==b){ a= b+3; }
else{ b++; }
}
}
After:
public class Aclass {
public void method(int a,
int b)
{
if(a==b){ a= b+3; }
else{ b++; }
}
}
2.4 Line Length
Description
This feature checks a source code file to see if any lines exceed a set number of characters. By default FixStyle limits the max number of characters on a line at 80. If a line exceeds the set max, then FixStyle breaks up the line at a logically sound place.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Wrapping". (4.) In the corresponding panel that appears on the right side of the window select the "General" tab. (5.) Click the "Wrap Line" check box and select a number from the "Line length:" drop down menu, or double click on the text box and enter your own number. (6.) In the Policy box check all options, except "Wrap before operators". (7.) Click OK. (8.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: Default Of 80 Characters
Before:
public static int veryLongMethodName (int veryLongParameterA, int veryLongParameterB, int veryLongParameterC )
{
After:
public static int veryLongMethodName (int veryLongParameterA,
int veryLongParameterB,
int veryLongParameterC )
{
2.5 Method Parameter Pad
Description
This feature checks a source code file to see if any method's parameter spacing differs from the style selected. FixStyle provides three different styles:
- No Space
- One Space (default)
- New Line.
How To Use This Feature
To enable this feature:
No Space: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "White Space". (4.) In the corresponding panel that appears on the right side of the window unclick "Method declaration parentheses" check box and unclick "Method call parentheses" checkbox. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
One Space: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "White Space". (4.) In the corresponding panel that appears on the right side of the window unclick "Method declaration parentheses" check box and unclick "Method call parentheses" checkbox. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
New Line: (1.) Select the Tools Menu and click "FixStylePreferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Wrapping". (4.) In the corresponding panel that appears on the right side of the window select the "Always" tab. (5.) In the section Wrap always click "Method left parentheses" checkbox. (6.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: No Space
Before:
int method (int a, int b)
{
}
After:
int method(int a, int b)
{
}
Example: One Space
Before:
int method (int a, int b)
{
}
After:
int method (int a, int b)
{
}
Example: New Line
Before:
int method (int a, int b)
{
}
After:
int method
(int a, int b)
{
}
2.6 Single Line Braces
Description
This feature checks a source code file for optional braces in control statements. If they are not used, FixStyle adds braces according to the style specified under "Left Curly Brace" and "Right Curly Brace".
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Braces". (4.) In the corresponding panel that appears on the right side of the window select the Misc Tab. (5.) Under the Insert braces section click the "if...else" check box, the "for" check box, the "while" check box, and the "do...while" check box. (6.) Click OK. (7.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
if(a<b)
a=b*2;
else
b--;
After:
if(a<b)
{
a=b*2;
}
else
{
b--;
}
2.7 Paren Pad
Description
This feature checks if the whitespace around parenthesis matches the selected style. FixStyle provides two styles:
- Spaces. FixStyle places one space after the left parenthesis and one space before the right
- No spaces. FixStyle sets the default the padding to no spaces
If the whitespace does not match the selected style, it changes so that it does.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Braces". (4.) In the corresponding panel that appears on the right side of the window select the "General" tab. (5.) In the Styles box click "Custom style" check box. (6.) In the "White Space" box select '1' from the "Before left brace:" drop down menu and select the number of spaces from the "Before right brace:" drop down menu.(7.) Click OK. (8.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: Spaces
Before:
int method( int a, int b)
After:
int method( int a, int b )
Example: No Spaces
Before:
int method( int a, int b)
After:
int method(int a, int b)
2.8 Tab To Spaces
Description
This feature checks for groups of space characters and any tab characters in the code. The user can convert groups of spaces into tab characters or tab characters into spaces. FixStyle sets the default number of spaces at 4.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Indentation". (4.) In the corresponding panel that appears on the right side of the window select the "Misc" tab. (5.) Unclick "Use tabs to indent" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: Tab To 3 Spaces
Before:
int a;
After:
int a;
Example: 3 Spaces To Tab
Before:
int a;
After:
int a;
2.9 Whitespace Around
Description
This feature checks a source code file to see if the desired amount of whitespace surrounds the tokens. If FixStyle cannot find the proper amount of whitespace around the tokens, then it adds the necessary spaces.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "White Space". (4.) In the corresponding panel that appears on the right side of the window click the check boxes labeled: "Assignment operators", "Bitwise Operators", "Logical operators", "Mathematical operators", "Relational operators", "Shift Operators" and "Type cast parentheses". (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
a=b+c;
After:
a = b + c;
2.10 Newline At End Of File
Description
This feature checks to see if the file ends with a newline character. If the file does not end with a newline character, this feature adds a newline character to the end of the file.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Misc". (4.) In the corresponding panel that appears on the right side of the window click "Insert trailing newline" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
...
myObject.cleanUp();
return;
}[EOF]
After:
...
myObject.cleanUp();
return;
}
[EOF]
2.11 Enforce Javadocs
Description
This feature checks for javadocs above every method or class. If FixStyle does not find the proper javadoc tags, this feature adds the missing javadoc tags.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Javadoc". (4.) In the corresponding panel that appears on the right side of the window select the "General" tab. (5.) In the "Generation" box click all of the check boxes for each of the Classes/Interface, Constructors, Methods, and Variables. (6.) Click the "Include inner classes" check box. (7.) Click OK. (8.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
}
public int getNum ()
{
After:
}
/**
* Write a description of method getNum here.
*
* @author (your name)
* @version (a version number or a date)
*/
public int getNum ()
{
2.12 Set Indent Width
Description
This feature indents all logical blocks of code a specified number of characters (spaces).
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Indentation". (4.) In the corresponding panel that appears on the right side of the window click "Use tabs to indent" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example: Indent 6 Spaces
Before:
public int getNum ()
{
if ( 5 > 4 )
return 5;
else
return 4;
}
After:
public int getNum ()
{
if ( 5 > 4 )
return 5;
else
return 4;
}
2.13 Array Trailing Comma
Description
This feature checks multi-line array initializations in the file. This feature makes sure that the last item ends with a comma. If it does not end with a comma, this feature adds one. When turned off, this feature will also remove the comma after the last item of such an initialization. NOTE: The "Wrap after element" feature under Printer->Wrapping->Misc->Arrays needs to be on in order to maintain multi-line array initializations.
How To Use This Feature
To enable this feature: (1.) Select the Tools Menu and click "FixStyle Preferences". (2.) In the Preferences window expand "Printer" from the list in the left hand window. (3.) In the subdirectory of Printer choose "Misc". (4.) In the corresponding panel that appears on the right side of the window click "Array trailing comma" check box. (5.) Click OK. (6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
int[] a = {
1,
2,
3
};
After:
int[] a = {
1,
2,
3,
};
2.14 Default Comes Last
Description
This feature assures that if there is a switch statement, that there is a default case within the switch statement. If there is a default case already, then no changes are made. The assertion of the default case places a assertFalse within the case statement to notify the user.
How To Use This Feature
To enable this feature:
(1.) Select the Tools Menu and click "FixStyle Preferences".
(2.) In the Preferences window expand "Printer" from the list in the left hand window.
(3.) In the subdirectory of Printer choose "Misc".
(4.) In the corresponding panel that appears on the right side of the window click "Default Comes Last" check box.
(5.) Click OK.
(6.) FixStyle activates this feature and reconfigures the next time the user runs it.
Example
Before:
switch(x){
case one: {
return 1;
break;
}
case two: {
return 2;
break;
}
}
After:
switch(x){
case one: {
return 1;
break;
}
case two: {
return 2;
break;
}
default: junit.framework.Assert.assertFalse("Default not set", true);
}
3.0 Features of FixStyle
- Each option in the settings panel creates a change in the Preview Panel
- Error Messages when accessing a file without read/write permissions gives the message "You do not have permission to access this file/directory"
- When the "Edit Style Conventions" button is clicked multiple times only one Settings Panel is displayed.
4.0 Other Jalopy Features Available
Each option is found under the "Printer" menu in the Preferences window.
Braces
Insert empty statement: An empty statement is added to empty braces to improve source code clarity
Cuddle braces: Empty braces will be put right next to the control statement.
Wrapping
Always: Choose to wrap the line after each option always:
Before extends keyword
After extends types
Before implements keyword
After implements keyword
Before throws keyword
After throws keyword
Method declaration parameters
Method call chains
Method call parameters
Method call parameters if nested Ternary expression ?
Ternary expression :
Labels
Always when exceed: wrap when the line will exceed maximum length
After extends types
After implements types
After throws types
After parameters/expressions
Blank Lines
Blank lines after:
Package statement
Last import statement
Classes
Interfaces
Methods
Left curly brace
Blank lines before and after:
Blocks
Declarations
Blank lines before:
Case blocks
Control statements
Single-line comments
Multi-line comments
Javadoc comments
Right curly brace
Keep up to ānā blank lines: Choose a number upt to
Comments
Removal of Single-line comments
Removal of Multi-line comments
Removal of Javadoc comments
Imports
Sort import statements: Sorts all imports lexicographically
Expand on-demand imports: Removes wild card imports (ones with '.*') and replaces with single-type imports used in the source code
Collapse single-type imports: Tries to collapse single-type imports to on-demand or wild card imports
Header
Insert Header: Inserts the given header template
Delete Header: Choose a header to delete with the given key
Blank Lines: Insert number of blank lines to separate header
Footer
Insert Footer: Inserts the given footer template
Delete Footer: Choose a footer to delete with the given key
Blank Lines: Insert number of blank lines to separate footer
Sorting
Declarations: can set declarations to be ordered as well as setting the order
Modifiers: can set modifiers to be ordered as well as setting the order
Misc
Insert expression parenthesis: Breaks up expressions using parenthesis by operation precedence
Insert serial version UID: a unique serial UID is given to the classes
Insert logging conditional: Checks if debugger is enabled before writing to it
Force formatting: If the history switch is enabled, will allow for all copies to be changed
Use history file: History saved in history.dat instead of the header
Use history comments: A small comment line is added every time the file is formatted
Set number of backups and location: Set the number of backups (up to 30) default is 0 and where to save them
Set number of threads: Set number of threads, should be equal to number of processors

