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



title
5.6.2.10.8 Chunks

Comments separate alignment chunks

Comments separate alignment chunks

Subdivides source code chunks by comments.

Chunks are source code elements which are logically grouped. For instance, all consecutive fields represent a source code chunk or all consecutive method calls represent a chunk and so on.

Examples of source code chunks:

class myClass {                         
    
float a, b, c;                             // field declaration
    
int d, e;                                  // field declaration
                                        
    
void main() {                       
       
String g;                               // variable eclaration
                                        
       
System.out.println("Hello World !");    // method call
       
myFunction();                           // method call
                                        
       
d = bla();                              // assingment
       
b = c + 1;                              // assingment
       
e = (a < 10);                           // assingment
       
...                              
    }                                   
}                                       


All alignment settings are related to chunks: Jindent only aligns elements within the same source code chunk. The result is a logical separated formatting output.

Setting "Comments separate alignment chunks" is able to subdivide these chunks if it finds comments.


Separate chunks by comments:

int a, b, c, d;           // trailing comment
int e, f, g, h, i, j;     // trailing comment
                                        
/* String declarations */               
char * k, l, m, n, o, p, q;    // trailing comment
char * r, s, t, u, v, w;       // trailing comment

Comment /* String declarations */ subdivides the variable declarations chunk into two subchunks. As a result the trailing comments of first and second chunk are aligned different.


Do not separate chunks by comments:

int a, b, c, d;                // trailing comment
int e, f, g, h, i, j;          // trailing comment
                                        
/* String declarations */               
char * k, l, m, n, o, p, q;    // trailing comment
char * r, s, t, u, v, w;       // trailing comment

All variable declarations belong to one source code chunk, even if a comment appears within these chunks. As a result the trailing comments are aligned all together.

See also... See also: Exceeding lines separate alignment chunks




Exceeding lines separate alignment chunks

Exceeding lines separate alignment chunks

Subdivides source code chunks by exceeding lines.

(For a detailed definition of 'source code chunks' please refer to the introduction of setting "Comments separate alignment chunks")


Separate chunks by exceeding lines:

char * abc    = "abc";                                      |
char * defghi = "defghi";                                   |
ALongClassName andALongFieldName =                          |
                   
new ALongClassName("12345","6789");      |
long var        = 1214159583925L;                           |
char * jklmnopq = "jklmnopq";                               |

Variable declaration andALongFieldName subdivides the variable declarations chunk into two subchunks. As a result the assignment of first and second chunk are aligned different.


Do not separate chunks by exceeding lines:

char * abc      = "abc";                
char * defghi   = "defghi";             
ALongClassName andALongFieldName =      
                   
new ALongClassName("12345","6789");
long var        = 1214159583925L;       
char * jklmnopq = "jklmnopq";           

All variable declarations belong to one source code chunk, even if an exceeding variable decalaration appears within these chunks. As a result the assignments are aligned all together.

See also... See also: Comments separate alignment chunks