OverviewDownloadDocumentationPlug-insLinksContact
Features | History | Manual | FAQ | Javadoc
This page generated: June 8 2004

4.3.5. Blank Lines

Controls the Jalopy Blank Lines settings: the insertion of blank lines to separate statements or declarations with different functions or meanings.

4.3.5.1. General

Lets you specify the general blank lines sizes for different Java source file elements.

  • Package statement

    Lets you control how many blank lines should be printed after the package statement.

    Example 4.115. 3 Blank lines after package statement

    package de.hunsicker.jalopy.printer;
    <--
    <--
    <--
    import antlr.collections.AST;
    
    import de.hunsicker.jalopy.parser.JavaAST;
    import de.hunsicker.jalopy.parser.JavaTokenTypes;
    
    ...
    

  • Last import statement

    Lets you control how many blank lines should be printed after the last import statement.

    Example 4.116. 4 Blank lines after last import statement

    package de.hunsicker.jalopy.printer;
    
    import antlr.collections.AST;
    
    import de.hunsicker.jalopy.parser.JavaAST;
    import de.hunsicker.jalopy.parser.JavaTokenTypes;
    <--
    <--
    <--
    <--
    public class Printer
    {
        ...
    }
    

  • Classes

    Lets you control how many blank lines should be printed between two class declarations.

    Example 4.117. 2 Blank lines between two class declarations

    class One
    {
        ...
    }
    <--
    <--
    class Two
    {
        ...
    }
    

  • Interfaces

    Lets you control how many blank lines should be printed between two interface declarations.

    Example 4.118. 3 Blank lines between two interface declarations

    interface One
    {
        ...
    }
    <--
    <--
    <--
    interface Two
    {
        ...
    }
    

  • Methods

    Lets you control how many blank lines should be printed between two method/constructor declarations.

    Example 4.119. 3 Blank lines between two method declarations

    public static Printer getInstance()
    {
        return INSTANCE;
    }
    <--
    <--
    <--
    public void print(AST node, ASTWriter out)
               throws IOException
    {
        ...
    }
    

  • Blocks

    Lets you control how many blank lines should be printed before and after statement blocks (if-else , for, while, do-while, switch, try-catch-finally, synchronized). Note that the 'Blank lines after' setting also applies for anonymous inner classes.

    Example 4.120. 2 Blank lines between before and after blocks

    AST type = null;
    <--
    <--
    switch (next.getType())
    {
        case JavaTokenTypes.LPAREN :
            type = PrinterUtils.advanceToFirstNonParen(next);
            break;
        default :
            type = next;
            break;
    }
    <--
    <--
    AST ident = type.getFirstChild();
    

  • Declarations

    Lets you control how many blank lines should be printed before and after variable declarations.

  • Case blocks

    Lets you control how many blank lines should be printed before each case block of a switch expression.

    Example 4.121. 3 Blank lines before case blocks

    switch (next.getType())
    {
    <--
    <--
    <--
        case JavaTokenTypes.LPAREN :
            type = PrinterUtils.advanceToFirstNonParen(next);
            break;
    <--
    <--
    <--
        default :
            type = next;
            break;
    }
    

  • Control statements

    Lets you control how many blank lines should be printed before the statements return, break and continue.

    Example 4.122. 2 Blank lines before case control statements

    switch (next.getType())
    {
        case JavaTokenTypes.LPAREN :
            type = PrinterUtils.advanceToFirstNonParen(next);
    <--
    <--
            break;
    
        default :
            type = next;
    <--
    <--
            break;
    }
    

  • Single-line comments

    Lets you control how many blank lines should be printed before single-line comments.

  • Multi-line comments

    Lets you control how many blank lines should be printed before multi-line comments.

  • Javadoc comments

    Lets you control how many blank lines should be printed before Javadoc comments.

4.3.5.2. Misc

Lets you control miscellaneous separation settings.

4.3.5.2.1. Misc
  • Blank lines after left curly brace

    Forces the given number of blank lines after left curly braces no matter what your other blank lines settings say.

    Example 4.123. Blank lines before blocks=1

    public void foo()
    {
    <--
        if (condition())
        {
    <--
            if (anotherCondition())
            {
                doSomething();
            }
        }
    }
    

    Example 4.124. Blank lines before blocks=1, Blank lines after left curly braces=0

    public void foo()
    {
        if (condition())
        {
            if (anotherCondition())
            {
                doSomething();
            }
        }
    }
    

  • Blank lines before right curly brace

    Forces the given number of blank lines before closing curly braces no matter what your other blank lines settings say.

    Example 4.125. Blank lines before blocks=1

    public void foo()
    {
        if (condititon())
        {
            if (anotherCondition())
            {
                doSomething();
    <--
            }
    <--
        }
    <--
    }
    

  • Keep Blank lines up to

    If enabled, retains up to the given number of blank lines found in the original source. This only works for method or constructor bodies. Note that Jalopy still takes your other blank lines settings into account.

    Example 4.126. Source code with blank lines to separate code sections

    aMVString = new MultiValueString("abc");
    <--
    System.out.println("MV = "+aMVString);
    <--
    System.out.println("MV0 = "+aMVString.extract(0));
    System.out.println("MV1 = "+aMVString.extract(1));
    System.out.println("MV2 = "+aMVString.extract(2));
    System.out.println("");
    

    If this feature is left disabled, Jalopy will print the individual lines according to the current blank lines settings but won't try to retain any blank lines.

4.3.5.2.2. Chunks

Lets you define what makes a chunk: a section of associated statements.

  • By comments

    If enabled, a statement with a comment before is recognized as the start of a new chunk.

    Example 4.127. Aligning variable declarations

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

    Example 4.128. Aligning variable declarations with chunking by comments

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

  • By Blank lines

    If enabled, a statement which has one or more blank lines before is recognized as the start of a new chunk.

4.3.5.3. Comments

Lets you control the behaviour of the separator comments. If the sorting of class elements is enabled, Separator comments can be inserted before every element section, to make it easier to identify the different parts of a source file.

Example 4.129. Separator comment

//~ Methods ------------------------------------------------------------------

4.3.5.3.1. General
  • Add separator comments

    Enables the insertions of separator comments.

  • Add separator comments for inner classes

    The insertion of separator comments for inner classes/interfaces may lead to confusion, therefore you can control it here separately.

4.3.5.3.2. Descriptions

Lets you define the description text for each of the different class elements.

4.3.5.3.3. Fill character

Lets you define the fill character for the comments.

to top