Jindent - Java Source Code Formatter http://www.jindent.com
 



title
5.6.2.8.4 Statements

Blank lines before statements containing blocks

Blank lines before statements containing blocks

Inserts a specific number of blank lines before statements which contain blocks.
This feature separates bigger statements from other statments. The result is a source code output which statements are grouped into chunks separated by blank lines.

Inserting 1 blank line:

a = callMethod();                       
a++;                                    
                                       
if (a < 10) {                           
   ...                                  
}                                       


Inserting 0 blank lines:

a = callMethod();                       
a++;                                    
if (a < 10) {                           
   ...                                  
}                                       



We recommend to use this feature together with setting: "Blank lines after statements containing blocks"
For instance setting "Blank lines before statements containing blocks" and "Blank lines after statements containing blocks" to 1 blank line can create an output like:

void method()                           
{                                       
    
do {                                
       ...                              
    } 
while(x < n);                     
                                       
    a = callMethod();                   
    a++;                                
                                       
    
if (a < 10) {                       
       ...                              
    }                                   
                                       
    callOtherMethod();                  
}                                       

The output is separated into chunks which creates a clearly formatted structure.


Blank lines after statements containing blocks

Blank lines after statements containing blocks

Inserts a specific number of blank lines after statements which contain blocks.
This feature separates bigger statements from other statments. The result is a source code output which statements are grouped into chunks separated by blank lines.

Inserting 1 blank line:

do {                                    
   ...                                  
while(x < n);                         
                                       
a = callMethod();                       
a++;                                    


Inserting 0 blank lines:

do {                                    
   ...                                  
while(x < n);                         
a = callMethod();                       
a++;                                    



We recommend to use this feature together with setting: "Blank lines before statements containing blocks"
For instance setting "Blank lines before statements containing blocks" and "Blank lines after statements containing blocks" to 1 blank line can create an output like:

void method()                           
{                                       
   
do {                                 
      ...                               
   } 
while(x < n);                      
                                       
   a = callMethod();                    
   a++;                                 
                                       
   
if (a < 10) {                        
      ...                               
   }                                    
                                       
   callOtherMethod();                   
}                                       

The output is separated into chunks and from there it has a clearly formatted structure.


Insert blank lines between different statement types

Insert blank lines between different statement types

Inserts a specific number of blank lines between statements of a different types.
This feature separates different statement and results into a source code output which statements are grouped into chunks separated by blank lines.

Original input source code:

void main()                             
{                                       
   cout << 
"Hello World !";                // cout
   
callMethod();                           // method call
   
a = getSomething();                     // assingment
   
b = a + 1;                              // assingment
   
callAnotherMethod(a, b);                // method call
   
callEvenMoreMethods();                  // method call
   
a++;                                    // expression
   
...                                  
}                                       


Inserting 1 blank line and output looks like:

void main()                             
{                                       
   cout << 
"Hello World !";                // cout
                                       
   
callMethod();                           // method call
                                       
   
a = getSomething();                     // assingment
   
b = a + 1;                              // assingment
                                       
   
callAnotherMethod(a, b);                // method call
   
callEvenMoreMethods();                  // method call
                                       
   
a++;                                    // expression
   
...                                  
}                                       



Blank lines before break statement

Blank lines before break statement

Inserts a specific number of blank lines before break statements.


Inserting 1 blank line:

switch(value)                           
{                                       
   
case 1:                              
      x = x + 
10;                       
      y = x / 
2;                        
                                       
      
break;                            
                                       
   ...                                  
}                                       


Inserting 0 blank lines:

switch(value)                           
{                                       
   
case 1:                              
      x = x + 
10;                       
      y = x / 
2;                        
      
break;                            
                                       
   ...                                  
}                                       



Blank lines before continue statement

Blank lines before continue statement

Inserts a specific number of blank lines before continue statements.


Inserting 1 blank line:

if ( condition )                        
{                                       
   x = x + 
10;                          
   y = y / 
2;                           
                                       
   
continue;                            
}                                       


Inserting 0 blank lines:

if ( condition )                        
{                                       
   x = x + 
10;                          
   y = y / 
2;                           
   
continue;                            
}                                       



Blank lines before return statement

Blank lines before return statement

Inserts a specific number of blank lines before return statements.


Inserting 1 blank line:

int getA()                              
{                                       
   
int x = callMethod();                
   x = x + 
10;                          
                                       
   
return x;                            
}                                       


Inserting 0 blank lines:

int getA()                              
{                                       
   
int x = callMethod();                
   x = x + 
10;                          
   
return x;                            
}                                       



Blank lines before throw statement

Blank lines before throw statement

Inserts a specific number of blank lines before throw statements.


Inserting 1 blank line:

if ( x == null )                        
{                                       
   
text = createErrorText();            
                                       
   
throw text;                          
}                                       


Inserting 0 blank lines:

if ( x == null )                        
{                                       
   
text = createErrorText();            
   
throw text;                          
}                                       



Blank lines before goto statement

Blank lines before goto statement

Inserts a specific number of blank lines before goto statements.


Inserting 1 blank line:

if ( x == null )                        
{                                       
   
text = createErrorText();            
                                       
   
throw text;                          
}                                       


Inserting 0 blank lines:

if ( x == null )                        
{                                       
   
text = createErrorText();            
   
throw text;                          
}