X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fjalopy%2Fdocs%2Findentation.html;fp=utils%2Fjalopy%2Fdocs%2Findentation.html;h=0000000000000000000000000000000000000000;hb=1889827c44c51f6353fe8619e5d44b421158af23;hp=f016e9d36eccf38b007a5a076363f3943b6a1e84;hpb=47168f025aefdaa044802bd5f8f510ffe43a4808;p=jalview.git diff --git a/utils/jalopy/docs/indentation.html b/utils/jalopy/docs/indentation.html deleted file mode 100755 index f016e9d..0000000 --- a/utils/jalopy/docs/indentation.html +++ /dev/null @@ -1,445 +0,0 @@ - - - - - 4.3.3. Indentation - - -
Overview • - Download • - Documentation • - Plug-ins • - Links • - Contact
Features | - History | - Manual | - FAQ | - Javadoc
- This page generated: June 8 2004

4.3.3. Indentation

-Controls the indentation settings. - -

4.3.3.1. General

Lets you change the general indentation settings.

4.3.3.1.1. Policy

-Lets you choose the way lines should be indented. -

  • -Standard indent -

    -With standard indentation, lines will be indented according to the -current indentation level (Note that the indentation level changes as the block -or parentheses level changes). -

    Example 4.30. Method declaration (standard indented)

    -public void severalParameters(String one, int two, String three,
    -    StringObject four, AnotherObject five) {
    -...
    -}
    -

    Example 4.31. Method Call (standard indented)

    -vector.add(new AppServerReference(
    -        "RemoteApplicationManager",
    -        poa.create_reference_with_id("RemoteApplicationManager".getBytes(),
    -            RemoteApplicationManagerHelper.id())));
    -

    Example 4.32. Assignment (standard indented)

    -doublette[InteressentenPflegeController.GEBURTSDATUM] = versichertenResultSetRow[i].field[0]
    -    .substring(0, 2) + "."
    -    + versichertenResultSetRow[i].field[0].substring(2, 4) + "."
    -    + versichertenResultSetRow[i].field[0].substring(4, 6);
    -

  • -Deep indent -

    -Deep indentation means that lines will be indented relative to the current -parentheses or assignment offset. This way consecutive code sections are somewhat easier -to recognize at the downside of consuming more horizontal space. -

    Example 4.33. Method declaration (deep indented)

    -public void severalParameters(String one, int two, String three,
    -                              StringObject four, AnotherObject five) {
    -    ...
    -}
    -

    Example 4.34. Method Call (deep indented)

    -this.add(lbPunktzahl,
    -         new GridBagLayout(0, 1, 2, 1, 0.0, 0.0,
    -                           GribBagConstraints.WEST,
    -                           GribBagConstraints.NONE,
    -                           new Insets(0, GribBagConstraints.WEST,
    -                                      GribBagConstraints.WEST,
    -                                      GribBagConstraints.WEST), 0, 0));
    -

    Example 4.35. Assignment (deep indented)

    -doublette[Controller.GEBURTSDATUM] = versichertenResultSetRow[i].field[0]
    -                                     .substring(0, 2) + "."
    -                                     + versichertenResultSetRow[i].field[0]
    -                                       .substring(2, 4)
    -                                     + "."
    -                                     + versichertenResultSetRow[i].field[0]
    -                                       .substring(4, 6);
    -

4.3.3.1.2. Sizes

-Lets you set different indentation sizes. -

  • -General indent - -

    -Specifies the number of spaces to use for general indentation (Studies have -found that 2 to 4 spaces for indentation is optimal) -

    Example 4.36. 2 space general indent

    -public class Preferences
    -{
    -->private Preferences()
    -->{
    -->}
    -
    -->public static void main(String[] argv)
    -->{
    -->->de.hunsicker.jalopy.swing.PreferencesDialog.main(argv);
    -->}
    -}
    -

    Example 4.37. 4 space general indent

    -public class Preferences
    -{
    ---->private Preferences()
    ---->{
    ---->}
    -
    ---->public static void main(String[] argv)
    ---->{
    ---->--->de.hunsicker.jalopy.swing.PreferencesDialog.main(argv);
    ---->}
    -}
    -

  • -Leading indent - -

    -Specifies the number of spaces to prepend before every line printed. -

    Example 4.38. 6 space leading indent

    ------>public class Preferences
    ------>{
    ------>    private Preferences()
    ------>    {
    ------>    }
    -
    ------>    public static void main(String[] argv)
    ------>    {
    ------>        de.hunsicker.jalopy.swing.PreferencesDialog.main(argv);
    ------>    }
    ------>}
    -

  • -Continuation indent - -

    -Specifies the number of spaces that should be inserted in front of -continuation lines, i.e. the consecutive lines in case of a line wrap. -

    Example 4.39. 2 space continuation indent

    -if ((condition1 && condition2)
    -    ->|| (condition3 && condition4)
    -    ->|| !(condition5 && condition6)) {
    -    doSomethingAboutIt();
    -}
    -

    Example 4.40. 4 space continuation indent

    -if ((condition1 && condition2)
    -    --->|| (condition3 && condition4)
    -    --->|| !(condition5 && condition6)) {
    -    doSomethingAboutIt();
    -}
    -

  • -Trailing comment indent - - - -

    -Specifies the number of spaces to insert between trailing comments and the -preceding statement. -

    Example 4.41. 3 space trailing comment indent

    -new String[] {
    -    "Sunday",-->// Sunday
    -    "Monday",-->// Monday
    -    "Tuesday",-->// Tuesday
    -    "Wednesday",-->// Wednesday
    -    "Thursday",-->// Thursday
    -    "Friday",-->// Friday
    -    "Saturday"-->// Saturday
    -}
    -

  • -Original Tab indent -

    -Specifies the original tabular size of the source code. Some indentations -or alignments may fail, if you miss the correct size here. - - -

  • -Extends indent -

    -If enabled, specifies the whitespace to print before the extends -keyword in case it was printed on a new line. -

    Example 4.42. extends indentation with 6 spaces

    -public interface Channel
    ------->extends Puttable, Takable
    -{
    -    ...
    -}
    -

  • -Implements indent -

    -Specifies the whitespace to print before the implements -keyword in case it was printed on a new line. -

    Example 4.43. implements indentation with 8 spaces

    -public class SynchronizedBoolean
    -------->implements Comparable, Cloneable
    -{
    -    ...
    -}
    -

  • -Throws indent -

    -Specifies the whitespace to print before the throws -keyword in case it was printed on a new line. - -

    Example 4.44. throws indentation with 3 spaces

    -private static final File getDestinationFile(File dest, String packageName,
    -                                             String filename)
    --->throws IOException, FooException
    -{
    -    ...
    -}
    -

4.3.3.2. Misc

  • -Use tabs to indent - -

    -Normally, Jalopy uses spaces to indent lines. If you prefer tabs, check this box. -

  • -Indent "case" from "switch" -

    -The Sun Java code convention recommends a switch style where case statements -are not indented relative to the switch statement as a whole. However, this -option allows you to indent the case statements to make the entire switch -statement stand out. -

    Example 4.45. Switch statement (unindented)

    -switch (prio)
    -{
    -case Priority.ERROR_INT :
    -case Priority.FATAL_INT :
    -    color = Color.red;
    -    break;
    -
    -case Priority.WARN_INT :
    -    color = Color.blue;
    -    break;
    -
    -default:
    -    color = Color.black;
    -    break;
    -}
    -

    Example 4.46. Switch statement (indented)

    -switch (prio)
    -{
    ---->case Priority.ERROR_INT :
    ---->case Priority.FATAL_INT :
    ---->    color = Color.red;
    ---->    break;
    -
    ---->case Priority.WARN_INT :
    ---->    color = Color.blue;
    ---->    break;
    -
    ---->default:
    ---->    color = Color.black;
    ---->    break;
    -}
    -

  • -Indent labels - -

    -Specifies whether lables should be indented with the current indentation level. -

    Example 4.47. Unindented label

    -// advance to the first CLASS_DEF or INTERFACE_DEF
    -LOOP:
    -        for (AST child = tree.getFirstChild();
    -             child != null;
    -             child = child.getNextSibling())
    -        {
    -            switch (child.getType())
    -            {
    -                case JavaTokenTypes.CLASS_DEF :
    -                case JavaTokenTypes.INTERFACE_DEF :
    -                    next = child;
    -                    break LOOP;
    -                default :
    -                    break;
    -            }
    -        }
    -

    Example 4.48. Indented label

    -        // advance to the first CLASS_DEF or INTERFACE_DEF
    -        LOOP:
    -        for (AST child = tree.getFirstChild();
    -             child != null;
    -             child = child.getNextSibling())
    -        {
    -            switch (child.getType()) {
    -                case JavaTokenTypes.CLASS_DEF :
    -                case JavaTokenTypes.INTERFACE_DEF :
    -                    next = child;
    -                    break LOOP;
    -
    -                default :
    -                    break;
    -            }
    -        }
    -

  • -Indent first column comments -

    -Normally, all comments will be indented relative to their position in the code -to avoid that comments break the logical structure of the program. Some -developers may like to disable the indentation for first column comments -during the developing phase. -

    Example 4.49. First column comment (indented)

    -    public static Printer create(AST node)
    -    {
    -
    -        /*
    -        if (node == null)
    -        {
    -            return new NullPrinter();
    -        }
    -        */
    -        return create(node.getType());
    -    }
    -

    Example 4.50. First column comment (unindented)

    -    public static Printer create(AST node)
    -    {
    -
    -/*
    -        if (node == null)
    -        {
    -            return new NullPrinter();
    -        }
    -*/
    -        return create(node.getType());
    -    }
    -

4.3.3.3. Align

  • -Variable identifiers -

    -If enabled, aligns the identifiers of variable declarations. -

    Example 4.51. Variable identifiers

    -String text = "text";
    -int a = -1;
    -History.Entry entry = new History.Entry(text);
    -

    Example 4.52. Variable identifiers (aligned)

    -String        text = "text";
    -int           a = -1;
    -History.Entry entry = new History.Entry(text);
    -

  • -Variable assignments -

    -If enabled, aligns the assignment parts of variable declarations or, surprise, assignments. -

    Example 4.53. Variable assignments (aligned)

    -String text         = "text";
    -int a               = -1;
    -History.Entry entry = new History.Entry(text);
    -

    -If both variable alignment options are enabled, you can achieve a style like -the following: -

    Example 4.54. Variable identifiers/assignments (both aligned)

    -String        text  = "text";
    -int           a     = -1;
    -History.Entry entry = new History.Entry(text);
    -

    - -

  • -Method Def parameters -

    -If enabled, aligns the parameters of method declarations. This only applies if -all parameters will be wrapped; either because wrapping is forced or the -max. line length is reached. To force aligning, you have to enable the -wrapping for method parameters (See Method Def parameters). -

    Example 4.55. Method declaration parameters

    -public static File create(final File file,
    -                          File directory,
    -                          int backupLevel)
    -{
    -    ...
    -}
    -

    Example 4.56. Method declaration parameters (aligned)

    -public static File create(final File file,
    -                          File       directory,
    -                          int        backupLevel)
    -{
    -    ...
    -}
    -

  • -Method Call chains -

    -If disabled, indentation happens according to the current indentation level. -

    Example 4.57. Method Call chain (standard indented)

    -Fachschluesselerzeugung.createService()
    -.getNeuerFachschluesselServiceService(
    -    FachschluesselerzeugungService.FACHSCHLUESSEL_KZ_INTERESSENT);
    -

    -Otherwise indentation is performed relative to the column offset of the first chain link. -

    Example 4.58. Method Call chain (aligned)

    -Fachschluesselerzeugung.createService()
    -                       .getNeuerFachschluesselServiceService(
    -                            FachschluesselerzeugungService.FACHSCHLUESSEL_KZ_INTERESSENT);
    -

  • -Ternary expressions -

    -If disabled, ternary expressions are printed according to the current -indentation policy. -

    Example 4.59. Ternary operators (standard indented)

    -        alpha = (aLongBooleanExpression) ? beta    |
    -        : gamma;                                   |
    -

    Example 4.60. Ternary operators (deep indented)

    -        alpha = (aLongBooleanExpression) ? beta    |
    -                : gamma;                           |
    -

    -If enabled, the second operator will always be aligned relative to the first one. -

    Example 4.61. Ternary expresssions (aligned)

    -        alpha = (aLongBooleanExpression) ? beta    |
    -                                         : gamma;  |
    -

    -Note that this switch only takes affect, if indeed a line break was inserted -before the second expression. You can force such line breaks with the -Wrap always before ternary expression colon setting. -

4.3.3.4. Continuation

-Lets you specify extra indentation for consectutive lines of certain expressions. -

  • -Blocks -

    -The Sun brace style could make seeing the statement body difficult. To -workaround this problem, you may want to use continuation indentation in case you like this -brace style. This setting applies for if, for, while -and do-while blocks. -

    Example 4.62. Non-continuation indentation

    -if ((condition1 && condition2)
    -    || (condition3 && condition4)
    -    || !(condition5 && condition6)) { // BAD WRAPS
    -    doSomethingAboutIt();             // MAKE THIS LINE EASY TO MISS
    -}
    -

    Example 4.63. Continuation indentation

    -if ((condition1 && condition2)
    -        || (condition3 && condition4)
    -        || !(condition5 && condition6)) {
    -    doSomethingAboutIt();
    -}
    -

    -Refer to Section 4.3.1.1.1, “Styles” for the available brace style options. -

  • -Operators -

    -If enabled, indentation will be increased before an operand will be printed. -

    Example 4.64. Ternary expression (deep indented)

    -String comma = spaceAfterComma
    -               --->? COMMA_SPACE
    -               --->: COMMA;
    -

to top