OverviewDownloadDocumentationPlug-insLinksContact
Features | History | Manual | FAQ | Javadoc
This page generated: December 10 2003

4.3. Printer

Lets you control all printer related settings.

4.3.1. Braces

Controls the handling of curly braces (the Java block delimeters).

4.3.1.1. General

Controls how the enclosing block delimeters - left and right curly brace - are printed. You can either choose from a predefined set of common styles or build one on your own.

4.3.1.1.1. Styles

Controls which brace style will be used to lay out blocks.

  • C style

    Selects the C brace style. This style is sometimes called "Allman style" or "BSD style".

    Example 4.1. C style

    if (!isDone)
    {
        doSomething();
    }
    else
    {
        System.err.println("Finished");
    }
    

  • Sun style

    Selects the Sun brace style. Sometimes called "K&R style".

    Example 4.2. Sun style

    if (!isDone) {
        doSomething();
    } else {
        System.err.println("Finished");
    }
    

  • GNU style

    Selects the GNU brace style.

    Example 4.3. GNU style

    if (!isDone)
      {
        doSomething();
      }
    else
      {
        System.err.println("Finished");
      }
    

  • Custom style

    Selecting this option will enable you to freely choose between the different brace style options discussed below.

4.3.1.1.2. Wrapping

Controls the brace wrapping options.

  • Newline before left brace

    If enabled, always prints a newline before the left curly brace.

  • Newline after right brace

    If enabled, prints a newline after the left curly brace (when possible).

  • Treat class/method blocks different

    It is common in the Java developer community to have the opening brace at the end of the line of the keyword for all types of blocks (Sun brace style). One may find the C++ convention of treating class/interface and method/constructor blocks different from other blocks useful. With this switch you can achieve exactly that: if enabled, class/interface and method/constructor blocks are then always printed in C brace style (newline before left brace).

  • Treat class/method blocks different if wrapped

    With this switch enabled, the opening brace for class/interface or method/constructor blocks will always be printed on a new line (C style), if either the parameter list spawns several lines and a throws clause follows, or one of the possible clauses (extends, implements, throws) was wrapped.

4.3.1.1.3. Whitespace

Controls the indentation whitespace for the left and right curly brace.

  • Before left brace

    Number of spaces to print before the left curly brace.

  • After left brace

    Number of spaces to print after the left curly brace.

  • After right brace

    Number of spaces to print after the right curly brace.

4.3.1.2. Misc

Controls miscellaneous brace options.

4.3.1.2.1. Insert braces

Per definition braces are superfluous on single statements, but it is a common recommendation that braces should be always used in such cases. With this option, you can specify whether missing braces for single statements should be inserted for the control statements if, for, while and do-while.

Enabling this option for while statements would render

Example 4.4. Brace insertion

while (!isDone)
    doSomething();

into

while (!isDone)
{
    doSomething();
}

4.3.1.2.2. Remove braces

It is permittable to remove braces in case they are superfluous. This not only applies to the control statements if, for, while and do-while, but also to every block in general (remember a block is just a sequence of statements, local class declarations and local variable declaration statements within braces).

Example 4.5. Brace removal

for (int i = 0; i < 100; i++)
{
    sum += value[i];
}

would become

for (int i = 0; i < 100; i++)
    sum += value[i];

4.3.1.2.3. Empty braces

Controls how empty braces should be handled. If no option is selected, they are left untouched.

Example 4.6. Empty braces

if (in != null)
{
    try
    {
        in.close();
    }
    catch (IOException ignored)
    {
    }
}

All options don't apply to class/interface and method/constructor bodies but are only used for control statements and blocks.

  • Insert empty statement

    Inserts an empty statement to make it obvious for the reader that the empty braces are intentional.

    Example 4.7. Empty braces with empty statement

    if (in != null)
    {
        try
        {
            in.close();
        }
        catch (IOException ignored)
        {
            ;
        }
    }
    
  • Cuddle braces

    Cuddles the braces. They will be printed right after the control statement.

    Example 4.8. Cuddled empty braces

    if (in != null)
    {
        try
        {
            in.close();
        }
        catch (IOException ignored) {}
    }
    

to top