Controls when and how lines are wrapped.
Lets you control the general line wrapping options.
Enables or disables automatic line wrapping. When enabled, Jalopy tries to keep lines within the maximal line length and breaks statements across lines when necessary.
Disabling line wrapping does not mean that existing line breaks are kept, but rather that no effort is taken to keep lines in between the maximal line length upon reformatting
Lets you specify the maximal line length. Jalopy tries (more or less—depending on the used indentation scheme) to limit each line within the given length.
Lets you define the wrapping policy for operators. Line wrapping will often occur with statements that consist of several (possibly long) expressions. Here you specify whether line wrapping should occur before or after the expression operator.
When enabled, line breaks will be inserted before operators.
Example 2.105. Wrap before operators (Standard indented)
if ((condition1 && condition2)
|| (condition3 && condition4)
|| !(condition5 && condition6)) {
doSomethingAboutIt();
}
When enabled, line breaks will be inserted after operators.
Example 2.106. Wrap after operators (Standard indented)
if ((condition1 && condition2) ||
(condition3 && condition4) ||
!(condition5 && condition6)) {
doSomethingAboutIt();
}
Please note that wrapping for the comma and dot operator is currently always performed after the operators! If you happen to use Sun Brace styling, you might want to enable continuation indentation for blocks to let the statement body stand out. See “Block continuation indentation” for more information.
Lets you specify for which code elements line breaks should be kept.
When enabled, existing line breaks after the commas of declaration parameters are kept. Otherwise line wrapping is performed according to the current settings.
Since 1.6
Example 2.107. Nicely laid out method declaration
void test( String rName, boolean rPendandic ) { ... }
After formatting this code could look like this (because everything fits in one line):
But with the "Keep line breaks" option enabled, it may look like this:
Example 2.109. Method declaration after formatting with kept line breaks (Endline indented)
void test( String rName, boolean rPendandic ) { ... }
Alternatively, you might want to use the
//J:KEEP+ pragma comment
to keep line breaks on a case by case basis.
When enabled, existing line breaks after the commas of call arguments are kept. Otherwise line wrapping is performed according to the current settings.
Since 1.6
After formatting this code could look like this (because everything fits in one line):
But with the "Keep line breaks" option enabled, it may look like this:
Example 2.112. Method call after formatting with kept line breaks (Endline indented)
obj.method1( test,
test2,
test3 );
Alternatively, you might want to use the
//J:KEEP+ pragma comment
to keep line breaks on a case by case basis.
When enabled, existing line breaks before or after infix operators and the comma operator of method declaration parameters or method call arguments are kept. Otherwise line wrapping is performed according to the current settings.
Since 1.0
Example 2.113. Operators with forced line breaks
if ((condition1 && condition2)
|| (condition3 && condition4)
|| !(condition5 && condition6))
{
...
}
After formatting this code could look like this (because not everything fits in one line and not line breaks are forced):
Example 2.114. Operators after formatting (wrapping is done on-demand)
if ((condition1 && condition2) || (condition3 && condition4) ||
!(condition5 && condition6))
{
...
}
But with the "Keep line breaks" option enabled, it may look like this:
Example 2.115. Operators after formatting with kept line breaks
if ((condition1 && condition2) ||
(condition3 && condition4) ||
!(condition5 && condition6))
{
...
}
Please note that it does not matter what wrapping policy for operators you choose. Jalopy will keep line breaks even if the operators move!
When enabled, existing line breaks before or after the plus operator of concatenated string literals are kept. Otherwise line wrapping is performed according to the current settings.
Since 1.0.1
Example 2.116. Nicely laid out string constant
query = "select a.prop_text, " + " a.contest_title, " + " from contest a " + " where a.language_code = b.language_code " + " and b.bob = c.bob " + " and a.x = ? " + " order by a.bob, " + " c.language";
After formatting this code could look like this:
Example 2.117. String constant after formatting
query = "select a.prop_text, " + " a.contest_title, " + " from contest a " + " where a.language_code = b.language_code " + " and b.bob = c.bob " + " and a.x = ? " + " order by a.bob, " + " c.language";
But with the "Keep string concats" option enabled, it may look like this:
Example 2.118. String constant after formatting with "Keep line breaks" (Standard indented)
query = "select a.prop_text, " + " a.contest_title, " + " from contest a " + " where a.language_code = b.language_code " + " and b.bob = c.bob " + " and a.x = ? " + " order by a.bob, " + " c.language";
Please note that it does not matter what wrapping policy for operators you choose. Jalopy will keep line breaks even if the operators move!
When enabled, existing line breaks after the separator comma between individual array elements are kept. Otherwise line wrapping is performed according to the current settings if there can be no pragma comment found that indicates otherwise.
Since 1.5
Example 2.119. Array declarations
String[] foo = new String[] { "foo", }; String[] bar = new String[] { "bar", "car", };
Example 2.120. Array declarations after reformat
String[] foo = new String[] { "foo", }; String[] bar = new String[] { "bar", "car", };
Example 2.121. Array declarations after reformat with "Keep line breaks"
String[] foo = new String[] { "foo", }; String[] bar = new String[] { "bar", "car", };
Example 2.122. Array declarations with pragma comment to keep line breaks
String[] foo = new String[] { "foo", }; String[] bar = new String[] { //J:KEEP "bar", "car", };
Alternatively, you might want to use the
//J:KEEP+ pragma comment
to keep line breaks on a case by case basis.
When using endline indentation, line breaks may not always be kept because doing so would break the endline indent contract and lead to inconsistent indentation behavior. Enabling this option will cause Jalopy to keep existing line breaks even in such cases. Please note that this option is only available when endline indentation is enabled and any of the "Keep line breaks" options selected!
Since 1.8
When the option is disabled, Jalopy won’t keep the line break before the first call argument because it goes against the endline indentation rules.
Example 2.124. Method call - endline indented
String firstSymbol = eraseNonBreakingSpaceFromSymbol(symbol1,
symbol2);
But if you really favor keeping the line break, enabling the option would yield:
Example 2.125. Method call - line break kept
String firstSymbol = eraseNonBreakingSpaceFromSymbol(
symbol1, symbol2);
This option lets you control what is considered a string concatenation. By default, Jalopy treats the plus (+) operator as a string concatenation when either one of the operands is a string literal. But you might want to narrow this behavior to only treat two string literals as a string concatenation. Please note that this option is only available when any of the "Keep line breaks" options is selected!
Since 1.8
Example 2.126. String concatenations
String query = "select a.prop_text, " + " a.contest_title, " + " from contest a " + " where a.language_code = b.language_code "; String name = "Walther" + getNick();
When this option is disabled, all operators in the example above are considered string concatenations and therefore line breaks are kept.
Example 2.127. String concatenations
String query = "select a.prop_text, " + " a.contest_title, " + " from contest a " + " where a.language_code = b.language_code "; String name = "Walther" + getNick();
When enabled, only those plus operators with two string literals on either side would retain any line breaks like in the example above.
For complex expressions a common technique to enhance readability is to break the expression into several sub-expressions that can be stored in temporary variables that are placed on different lines.
Example 2.128. Complex expression
if (conditionOne && | ("foo".equals(aStr) || "bar".equals(aStr)) | doSomething(); |
Example 2.129. Refactored expression
boolean conditionTwo = "foo".equals(aStr); | boolean conditionThree = "bar".equals(aStr); | | if (conditionOne && | (conditionTwo || conditionThree)) | doSomething(); |
In order to determine occurrences of complex expressions, enabling this option will cause automatic line wrapping to be disabled when a complex expression gets printed. A warning message will be logged in the Printer category that informs you about the location of the expression.
Since 1.5
Example 2.130. Flagged complex expression
|
if (conditionOne && (conditionTwo || conditionThree))
doSomething(); |
With Endline indentation and "Wrap on-demand after left parenthesis" or "Keep line break for operators" enabled, line breaks after left parentheses may look ugly. If this option is enabled, such line breaks are avoided. This option was mainly introduced to fix some unwanted behavior of earlier releases without breaking compatibility. It is recommended to have it enabled.
Since 1.4
Example 2.131. Bare left parenthesis
this.customerNumber = new CustomerNumber( ServiceManager.createService());
Example 2.132. Avoided bare left parenthesis
this.customerNumber = new CustomerNumber(ServiceManager.createService());
This option lets you define where a line wrap should preferably occur for call statements after assignments that don’t fit into the maximal line length. The option is only meant to let you adjust behavior when “Prefer wrap after assignments” has been enabled. Please see explanation there.
Since 1.7
Example 2.133. Wrapping assignment expression
nuMBeans =
NuvegaPropertiesHandler.getNNuvegaArrayProperty(
NuvegaProperties.PROPERTIES_FILE_NUVEGA_BEAN_NAME);
Example 2.134. Prefer wrapping within call
nuMBeans = NuvegaPropertiesHandler.getNNuvegaArrayProperty(
NuvegaProperties.PROPERTIES_FILE_NUVEGA_BEAN_NAME);
This option lets you define where a line wrap should preferably occur for call arguments that does not fit into the maximal line length. Normally a line gets wrapped before a call argument that don’t fit into the maximal line length. Enabling this option will cause a line break inserted within the call argument for operator expressions when the operator expression is not immediately preceded with or followed by another operator expression.
Since 1.5
Example 2.135. Wrapping method call (default behavior)
failed(output, "a" + "b", null, | "Failed to open prefs: " + e.getMessage()); | |
As you can see from the above example a line break is inserted before the third argument as it would exceed the maximal line length when printed in the same line.
Example 2.136. Prefer wrapping within call argument
failed(output, "a" + "b", null, "Failed to open prefs: " | + e.getMessage()); | |
When the option is enabled, the line break happens within along the operator of the third argument.
Example 2.137. Standard wrapping when two operator expressions
failed(output, "a" + "b", | "Failed to open prefs: " + e.getMessage()); | |
But if two operator expressions follow immediately, the standard behavior applies in order to enhance readability.