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



title
5.6.2.8.6 Declarations

Blank lines before local variable declarations

Blank lines before local variable declarations

Inserts a specific number of blank lines before local variables declarations.


Inserting 1 blank line:

void method()                           
{                                       
    callMethod();                       
                                       
    
int a = 0;                          
    
int b = 10;                         
    ...                                 
}                                       


Inserting 0 blank lines:

void method()                           
{                                       
    callMethod();                       
    
int a = 0;                          
    
int b = 10;                         
    ...                                 
}                                       



Blank lines after local variable declarations

Blank lines after local variable declarations

Inserts a specific number of blank lines after local variables declarations.


Inserting 1 blank line:

void method()                           
{                                       
    
int a = 0;                          
    
int b = 10;                         
                                       
    callMethod(a, b);                   
}                                       


Inserting 0 blank lines:

void method()                           
{                                       
    
int a = 0;                          
    
int b = 10;                         
    callMethod(a, b);                   
}                                       



Blank lines after field declarations

Blank lines after field declarations

Inserts a specific number of blank lines after field declarations.


Inserting 2 blank lines:

class MyClass                           
{                                       
    
private int fieldA;                 
    
private int fieldB;                 
    
private String fieldC;              
                                       
                                       
    
void method()                       
    {                                   
        ...                             
    }                                   
}                                       


Inserting 1 blank line:

class MyClass                           
{                                       
    
private int fieldA;                 
    
private int fieldB;                 
    
private String fieldC;              
                                       
    
void method()                       
    {                                   
        ...                             
    }                                   
}                                       



Blank lines after class/struct and union declarations

Blank lines after class/struct and union declarations

Inserts a specific number of blank lines after class declarations.


Inserting 3 blank lines:

class MyClass                           
{                                       
    
private int fieldA;                 
    ...                                 
}                                       
                                       
                                       
                                       
class MyOtherClass                      
{                                       
    ...                                 
}                                       


Inserting 1 blank line:

class MyClass                           
{                                       
    
private int fieldA;                 
    ...                                 
}                                       
                                       
class MyOtherClass                      
{                                       
    ...                                 
}                                       



Blank lines after constructor and destructor declarations

Blank lines after constructor and
	destructor declarations

Inserts a specific number of blank lines after constructor and destructor declarations.


Inserting 2 blank lines:

class MyClass                           
{                                       
    MyClass()                           
    {                                   
        ...                             
    }                                   
                                       
                                       
    
void method()                       
    {                                   
        ...                             
    }                                   
}                                       


Inserting 1 blank line:

class MyClass                           
{                                       
    MyClass()                           
    {                                   
        ...                             
    }                                   
                                       
    
void method()                       
    {                                   
        ...                             
    }                                   
}                                       



Blank lines after function declarations

Blank lines after function declarations

Inserts a specific number of blank lines after method declarations.


Inserting 2 blank lines:

class MyClass                           
{                                       
    
void methodA(int a, int b)          
    {                                   
        ...                             
    }                                   
                                       
                                       
    
void methodB()                      
    {                                   
        ...                             
    }                                   
}                                       


Inserting 0 blank lines:

class MyClass                           
{                                       
    
void methodA(int a, int b)          
    {                                   
        ...                             
    }                                   
    
void methodB()                      
    {                                   
        ...                             
    }                                   
}                                       



Group empty functions for blank line insertion

Group empty functions for blank line insertion

Even if blank line insertions after method declarations improve the readability of source code a lot, the same feature may not be helpful for method declarations which contain no method bodies.
For that reason it is possible to group empty method declarations to one chunk and insert the blank lines after the whole groups.


Let's assume the setting to insert blank lines after methods is set to 2 and grouping of methods with empty bodies is disabled then we can get an output like:

extern STATUS bootBpAnchorExtract (const char * string, char ** pAnchorAdrs);
                                       
                                       
extern STATUS bootNetmaskExtract (const 
char * string, int * pNetmask);
                                       
                                       
extern STATUS bootScanNum (const 
char ** ppString, int * pValue, BOOL hex);
                                       
                                       
STATUS bootStructToString (const 
char * paramString, BOOT_PARAMS * pBootParams) {
   ...                                  
}                                       
                                       
                                       
typedef struct params {                 
   ...                                  
}                                       


The same source code with grouping enabled puts all forward method declarations to one chunk and separates it from the method declaration containing a method body:

extern STATUS bootBpAnchorExtract (const char * string, char ** pAnchorAdrs);
extern STATUS bootNetmaskExtract (const 
char * string, int * pNetmask);
extern STATUS bootScanNum (const 
char ** ppString, int * pValue, BOOL hex);
                                       
                                       
STATUS bootStructToString (const 
char * paramString, BOOT_PARAMS * pBootParams) {
   ...                                  
}                                       
                                       
                                       
typedef struct params {                 
   ...                                  
}                                       

See also... See also: Blank lines after function declarations




Blank lines after enum declarations

Blank lines after enum declarations

Inserts a specific number of blank lines after enumeration declarations.


Inserting 2 blank lines:

enum Coin                               
{                                       
    PENNY, NICKEL, DIME, QUARTER        
}                                       
                                       
                                       
Coin myCoin = PENNY;                    


Inserting 1 blank line:

enum Coin                               
{                                       
    PENNY, NICKEL, DIME, QUARTER        
}                                       
                                       
Coin myCoin = penny;                    



Blank lines after member declaration groups

Blank lines after member declaration groups

Inserts a specific number of blank lines after member declaration groups.


Inserting 2 blank lines:

class Test {                            
   
public:                              
      
int a;                            
      
int b;                            
                                       
                                       
   
private:                             
      
int x;                            
      
int y;                            
};                                      


Inserting 1 blank line:

class Test {                            
   
public:                              
      
int a;                            
      
int b;                            
                                       
   
private:                             
      
int x;                            
      
int y;                            
};                                      



Blank lines after using declarations

Blank lines after using declarations

Inserts a specific number of blank lines after using declarations.


Inserting 2 blank lines:

using std::cout;                        
using std::endl;                        
                                       
                                       
class Test {                            
   ...                                  
}                                       


Inserting 1 blank line:

using std::cout;                        
using std::endl;                        
                                       
class Test {                            
   ...                                  
}                                       



Blank lines after blocks of linkage specifications

Blank lines after blocks of linkage specifications

Inserts a specific number of blank lines after a block if linkage specification.


Inserting 2 blank lines:

extern "C" {                            
   ...                                  
}                                       
                                       
                                       
void method() {                         
   ...                                  
}                                       


Inserting 1 blank line:

extern "C" {                            
   ...                                  
}                                       
                                       
void method() {                         
   ...                                  
}