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



title
5.6.1.9.4 Method Calls

chained method and constructor call operator .

chained method and constructor call operator .

Controls how to wrap chained method calls operators.



Wrap always:

callMethodA()                           
    .callMethodB()                      
    .callMethodC()                      
    .callMethodD();                     

The wrapped line is indented by setting: "Indentation of wrapped chained constructor and method calls"


Wrap never:

callMethodA().callMethodB().callMethodC().callMethodD();

This wrapping mode never wraps chained method calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

callMethodA().callMethodB()        |
    
.callMethodC().callMethodD();  |

This wrapping mode wraps on demand:
If the chained method call fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length the line will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole chained method call exceeds maximal line length then the line will be wrapped completely.


We assume the following input source code example which exceeds maximal line length:

callMethodA()                      |
    
.callMethodB()                 |
    
.callMethodC()                 |
    
.callMethodD();                |

In this example token callMethodC() exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and it will be wrapped.
Indentation of wrapped line is done by setting: "Indentation of wrapped chained constructor and method calls"

See also... See also: Indentation of wrapped chained constructor and method calls , Align wrapped line to first chained method call dot .




Indentation of wrapped chained constructor and method calls

Indentation of wrapped chained constructor and method calls

Indents wrapped chained method call by a specified number of white spaces.

See also... See also: Align wrapped line to first chained method call dot .




Align wrapped line to first chained method call dot .

Align wrapped line to first chained method call dot .

Controls if wrapped chained method calls should be aligned to first chained method call dot.



Do not align chained method calls.

callMethodA()                           
    .callMethodB()                      
    .callMethodC()                      
    .callMethodD();                     

The wrapped line is indented by four spaces configured through setting: "Indentation of wrapped chained constructor and method calls"


Align chained method calls.

callMethodA().callMethodB()             
             .callMethodC()             
             .callMethodD();            

The wrapped line is indented by no spaces configured through setting: "Indentation of wrapped chained constructor and method calls"



Wrap before left parentheses (

Wrap before left parentheses (

Controls how to wrap before left parentheses of method/constructor calls.

Please note:This setting does not affect method/constructor calls without any parameters.


Wrap always:

public void method()                    
{                                       
    callMethod                          
        (argumentOne, argumentTwo);     
    ...                                 
}                                       

This wrapping mode wraps always before left parentheses of method/constructor calls even if the line would fit into the specified maximal line length.
The wrapped line is indented by setting: "Indentation of wrapped left parentheses ("


Wrap never:

public void method()                    
{                                       
    callMethod(argumentOne, argumentTwo);

    ...                                 
}                                       

This wrapping mode never wraps before left parentheses of method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()               |
{                                  |
    
callMethod                     |
        
(argumentOne, argumentTwo);     
    ...
                            |
}                                  |

This wrapping mode wraps on demand:
If the left parenthesis of method/constructor calls fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length the line will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole method/constructor call exceeds maximal line length then the line will be wrapped before its left parenthesis.


We assume the following input source code example which exceeds maximal line length:

public void method()               |
{                                  |
    
callMethod(argumentOne, argumentTwo);
    ...
                            |
}                                  |

In this example token argumentTwo exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and it will be wrapped after its left parenthesis:

public void method()                    |
{                                       |
    
callMethod                          |
        
(argumentOne, argumentTwo);     |
    
...                                 |
}                                       |

Indentation of wrapped line is done by setting: "Indentation of wrapped left parentheses ("

See also... See also: Indentation of wrapped left parentheses (




Indentation of wrapped left parentheses (

Indentation of wrapped left parentheses (

Indents wrapped left parentheses of method/constructor calls by a specified number of white spaces.

See also... See also: Wrap before left parentheses (




Wrap first argument

Wrap first argument

Controls how to wrap first argument of method/constructor calls.


Wrap always:

public void method()                    
{                                       
    callMethod(                         
        argumentOne, argumentTwo, argumentThree);

    ...                                 
}                                       

This wrapping mode wraps always the first argument of method/constructor calls even if the line would fit into the specified maximal line length.
The wrapped line is indented by setting: "Indentation of first wrapped argument"


Wrap never:

public void method()                    
{                                       
    callMethod(argumentOne, argumentTwo, argumentThree);

    ...                                 
}                                       

This wrapping mode never wraps first arguments of method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                         |
{                                            |
    
aPrettyLongObjectName.callMethod(        |
        
argumentOne, argumentTwo);           |
    
...                                      |
}                                            |

This wrapping mode wraps on demand:
If the first method/constructor call argument fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length it will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole method/constructor call exceeds maximal line length then the first argument will be wrapped.


We assume the following input source code example which exceeds maximal line length:

public void method()                  |
{                                     |
    
callMethod(argumentOne, argumentTwo);
    ...
                               |
}                                     |

In this example token argumentTwo exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and first argument will be wrapped:

public void method()                  |
{                                     |
    
callMethod(                       |
        
argumentOne, argumentTwo);    |
    
...                               |
}                                     |

Indentation of wrapped line is done by setting: "Indentation of first wrapped argument"



Indentation of first wrapped argument

Indentation of first wrapped argument

Indents first wrapped argument of method/constructor calls by a specified number of white spaces.

See also... See also: Wrap first argument




Wrap all other arguments

Wrap all other arguments

Controls how to wrap arguments of method/constructor calls.


Wrap always:

public void method()                    
{                                       
    callMethod(argumentOne,             
               argumentTwo,             
               argumentThree);          
    ...                                 
}                                       

This wrapping mode wraps always arguments of method/constructor calls even if the line would fit into the specified maximal line length.
Wrapped arguments will be be aligned to its corresponding first argument.


Wrap never:

public void method()                    
{                                       
    callMethod(argumentOne, argumentTwo, argumentThree);

    ...                                 
}                                       

This wrapping mode never wraps arguments of method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                    |
{                                       |
    
callMethod(argumentOne, argumentTwo,
               argumentThree);
          |
    
...                                 |
}                                       |

This wrapping mode wraps on demand:
If the arguments of method/constructor calls fit into specified maximal line length then they won't be wrapped. If they exceed maximal line length they will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole method/constructor call exceeds maximal line length then all arguments will be wrapped.


We assume the following input source code example which exceeds maximal line length:

public void method()                              |
{                                                 |
    
callMethod(argumentOne, argumentTwo, argumentThree);
    ...
                                           |
}                                                 |

In this example token argumentThree exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and all arguments will be wrapped:

public void method()                              |
{                                                 |
    
callMethod(argumentOne,                       |
               
argumentTwo,                       |
               
argumentThree);                    |
    
...                                           |
}                                                 |



Wrap right parentheses )

Wrap right parentheses )

Controls how to wrap right parentheses of method/constructor calls.

Please note:This setting does not affect method/constructor calls without any parameters.


Wrap always:

public void method()                    
{                                       
    callMethod(argumentOne, argumentTwo 
    );                                  
    ...                                 
}                                       

This wrapping mode wraps always right parentheses of method/constructor calls even if the line would fit into the specified maximal line length.


Wrap never:

public void method()                    
{                                       
    callMethod(argumentOne, argumentTwo);

    ...                                 
}                                       

This wrapping mode never wraps right parentheses of method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                   |
{                                      |
    
callMethod(argumentOne, argumentTwo 
    );
                                 |
    
...                                |
}                                      |

This wrapping mode wraps on demand:
If the right parenthesis of method/constructor calls fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length the right parenthesis will be wrapped to a new line though.


Wrapping mode if line exceeds works a bit different:
If the whole method/constructor call exceeds maximal line length then the line will be wrapped before its right parenthesis.


We assume the following input source code example which exceeds maximal line length:

public void method()                         |
{                                            |
    
callMethod(argumentOne, argumentTwo, argumentThree);
    ...
                                      |
}                                            |

In this example token argumentThree exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and right parenthesis will be wrapped:

public void method()                                             |
{                                                                |
    
callMethod(                                                  |
        
argumentOne,                                             |
        
argumentTwo,                                             |
        
argumentThree                                            |
    
);                                                           |
    
...                                                          |
}                                                                |
In this example we additionally set "Wrap first argument" and "Wrap right parentheses )" to if line exceeds too.



Indentation of wrapped right parentheses )

Indentation of wrapped right parentheses )

Indents wrapped right parentheses of method/constructor calls by a specified number of white spaces.


Indentation of 0:

public void method()                                             |
{                                                                |
    
callMethod(                                                  |
        
argumentOne,                                             |
        
argumentTwo,                                             |
        
argumentThree                                            |
    
);                                                           |
    
...                                                          |
}                                                                |


Indentation of 4:

public void method()                                             |
{                                                                |
    
callMethod(                                                  |
        
argumentOne,                                             |
        
argumentTwo,                                             |
        
argumentThree                                            |
        
);                                                       |
    
...                                                          |
}                                                                |

See also... See also: Wrap right parentheses )




Wrap before left parentheses (

Wrap before left parentheses (

Controls how to wrap before left parentheses of nested method/constructor calls.

Please note:This setting does not affect neszed method/constructor calls without any parameters.


Wrap always:

public void method()                    
{                                       
    callMehthodA(callMethodB            
        (argumentOne, argumentTwo));    
    ...                                 
}                                       

This wrapping mode wraps always before left parentheses of nested method/constructor calls even if the line would fit into the specified maximal line length.
The wrapped line is indented by setting: "Indentation of wrapped left parentheses ("


Wrap never:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne, argumentTwo));

    ...                                 
}                                       

This wrapping mode never wraps before left parentheses of nested method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                          |
{                                             |
    
callMethodA(callMethodB                   |
        
(argumentOne, argumentTwo));          |
    
...                                       |
}                                             |

This wrapping mode wraps on demand:
If the left parenthesis of nested method/constructor calls fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length the line will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole nested method/constructor call exceeds maximal line length then the line will be wrapped before its left parenthesis.


We assume the following input source code example which exceeds maximal line length:

public void method()                         |
{                                            |
    
callMethodA(callMethodB(argumentOne, argumentTwo));
    ...
                                      |
}                                            |

In this example token argumentTwo exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and it will be wrapped after its left parenthesis:

public void method()                    |
{                                       |
    
callMethodA(callMethodB             |
        
(argumentOne, argumentTwo));    |
    
...                                 |
}                                       |

Indentation of wrapped line is done by setting: "Indentation of wrapped left parentheses ("

See also... See also: Indentation of wrapped left parentheses (




Indentation of wrapped left parentheses (

Indentation of wrapped left parentheses (

Indents wrapped left parentheses of nested method/constructor calls by a specified number of white spaces.

See also... See also: Wrap before left parentheses (




Wrap first argument

Wrap first argument

Controls how to wrap first argument of nested method/constructor calls.


Wrap always:

public void method()                    
{                                       
    callMethodA(callMethodB(            
        argumentOne, argumentTwo, argumentThree));

    ...                                 
}                                       

This wrapping mode wraps always the first argument of nested method/constructor calls even if the line would fit into the specified maximal line length.
The wrapped line is indented by setting: "Indentation of first wrapped argument"


Wrap never:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne, argumentTwo, argumentThree));

    ...                                 
}                                       

This wrapping mode never wraps first arguments of nested method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                                           |
{                                                              |
    
aPrettyLongObjectName.callMethod(callAnotherMethod(        |
        
argumentOne, argumentTwo));                            |
    
...                                                        |
}                                                              |

This wrapping mode wraps on demand:
If the first nested method/constructor call argument fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length it will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole nested method/constructor call exceeds maximal line length then the first argument will be wrapped.


We assume the following input source code example which exceeds maximal line length:

public void method()                              |
{                                                 |
    
callMethodA(callMethodB(argumentOne, argumentTwo));
    ...
                                           |
}                                                 |

In this example token argumentTwo exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and first argument will be wrapped:

public void method()                              |
{                                                 |
    
callMethodA(callMethodB(                      |
        
argumentOne, argumentTwo));               |
    
...                                           |
}                                                 |

Indentation of wrapped line is done by setting: "Indentation of first wrapped argument"



Indentation of first wrapped argument

Indentation of first wrapped argument

Indents first wrapped argument of nested method/constructor calls by a specified number of white spaces.

See also... See also: Wrap first argument




Wrap all other arguments

Wrap all other arguments

Controls how to wrap arguments of nested method/constructor calls.


Wrap always:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne,

                            argumentTwo,

                            argumentThree));

    ...                                 
}                                       

This wrapping mode wraps always arguments of nested method/constructor calls even if the line would fit into the specified maximal line length.
Wrapped arguments will be aligned to its corresponding first argument.


Wrap never:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne, argumentTwo, argumentThree));

    ...                                 
}                                       

This wrapping mode never wraps arguments of nested method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                                 |
{                                                    |
    
callMethodA(callMethodB(argumentOne, argumentTwo,
                            argumentThree();
         |
    
...                                              |
}                                                    |

This wrapping mode wraps on demand:
If the arguments of nested method/constructor calls fit into specified maximal line length then they won't be wrapped. If they exceed maximal line length they will be wrapped though.


Wrapping mode if line exceeds works a bit different:
If the whole nested method/constructor call exceeds maximal line length then all arguments will be wrapped.


We assume the following input source code example which exceeds maximal line length:

public void method()                                           |
{                                                              |
    
callMethodA(callMethodB(argumentOne, argumentTwo, argumentThree));
    ...
                                                        |
}                                                              |

In this example token argumentThree exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and all arguments will be wrapped:

public void method()                                           |
{                                                              |
    
callMethodA(callMethodB(argumentOne,                       |
                            
argumentTwo,                       |
                            
argumentThree));                   |
    
...                                                        |
}                                                              |



Wrap right parentheses )

Wrap right parentheses )

Controls how to wrap right parentheses of nested method/constructor calls.

Please note:This setting does not affect nested method/constructor calls without any parameters.


Wrap always:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne, argumentTwo

    ));                                 
    ...                                 
}                                       

This wrapping mode wraps always right parentheses of nested method/constructor calls even if the line would fit into the specified maximal line length.


Wrap never:

public void method()                    
{                                       
    callMethodA(callMethodB(argumentOne, argumentTwo));

    ...                                 
}                                       

This wrapping mode never wraps right parentheses of nested method/constructor calls even if the line does not fit into the specified maximal line length.


Wrap on demand:

public void method()                                |
{                                                   |
    
callMethodA(callMethodB(argumentOne, argumentTwo
    ));
                                             |
    
...                                             |
}                                                   |

This wrapping mode wraps on demand:
If the right parenthesis of nested method/constructor calls fits into specified maximal line length then it won't be wrapped. If it exceeds maximal line length the right parenthesis will be wrapped to a new line though.


Wrapping mode if line exceeds works a bit different:
If the whole nested method/constructor call exceeds maximal line length then the line will be wrapped before its right parenthesis.


We assume the following input source code example which exceeds maximal line length:

public void method()                                      |
{                                                         |
    
callMethodA(callMethodB(argumentOne, argumentTwo, argumentThree));
    ...
                                                   |
}                                                         |

In this example token argumentThree exceeds the specified maximal line length, therefore we consider this case as 'the line exceeds maximal line length' and right parenthesis will be wrapped:

public void method()                                                          |
{                                                                             |
    
callMethodA(callMethodB(                                                  |
        
argumentOne,                                                          |
        
argumentTwo,                                                          |
        
argumentThree                                                         |
    
));                                                                       |
    
...                                                                       |
}                                                                             |
In this example we additionally set "Wrap first argument" and "Wrap right parentheses )" to if line exceeds too.



Indentation of wrapped right parentheses )

Indentation of wrapped right parentheses )

Indents wrapped right parentheses of nested method/constructor calls by a specified number of white spaces.


Indentation of 0:

public void method()                                                          |
{                                                                             |
    
callMethodA(callMethodB(                                                  |
        
argumentOne,                                                          |
        
argumentTwo,                                                          |
        
argumentThree                                                         |
    
));                                                                       |
    
...                                                                       |
}                                                                             |


Indentation of 4:

public void method()                                                          |
{                                                                             |
    
callMethodA(callMethodB(                                                  |
        
argumentOne,                                                          |
        
argumentTwo,                                                          |
        
argumentThree                                                         |
        
));                                                                   |
    
...                                                                       |
}                                                                             |

See also... See also: Wrap right parentheses )




Wrap chained constructor and method calls

Wrap chained constructor and method calls

Determines whether line breaks are allowed in chained method calls or not.


Allow wrapping of chained method calls:

public void method()                                   |
{                                                      |
    
mypackage.jindent.utils.                           |
         
.ClassName.staticMethodCall(a, b);            |
    
...                                                |
}                                                      |

Indentation of wrapped line is done by setting: "General indentation size"


Do not allow wrapping of chained method calls:

public void method()                                   |
{                                                      |
    
mypackage.jindent.utils.ClassName.staticMethodCall(a, b);
    ...
                                                |
}                                                      |