This document describes the changes in the Java formatter engine of Jalopy 1.1 that may have an impact on formatting style (depending on your code convention).
Spurious blank spaces were inserted before and after HTML tags for inline Javadoc tags
/**
* Invokes {@link #get(Convention.Key, String) <tt>get(key,null)</tt>}
*/
was wrongly formatted as
/**
* Invokes {@link #get(Convention.Key, String) <tt> get(key,null) </tt>}
*/ ^ ^ ^
and after the 2nd run
/**
* Invokes {@link #get(Convention.Key, String) <tt> get(key,null) </tt>}
*/ ^^ ^^ ^^
Comments before closing curly braces could lead to wrong indentation when using endline indent policy. Additionally multiple comments were not correctly lined up
try { int x = 1000; //} catch (NullPointerException ex) { // ex.printStackTrace(); } catch (RuntimeException ex) { ; }
was wrongly formatted as
try { int x = 1000; //} catch (NullPointerException ex) { // ex.printStackTrace(); } catch (RuntimeException ex) { ; }
Now it does (depending on the code convention)
try { int x = 1000; //} catch (NullPointerException ex) { // ex.printStackTrace(); } catch (RuntimeException ex) { ; }
Comments before closing curly braces were only indented according to the current indentation level when the column offset of the comment was greater than the column offset of the brace. Now such comments are always indented (the only exception being 1st column comments, these are always printed according to the associated convention setting)
void method() { // intentionally left blank }
was formatted as
void method() { // intentionally left blank }
Now it does (depending on the code convention)
void method() { // intentionally left blank }
Comments below multi-variables were wrongly indented when the endline indentation policy was used
int hhcGoalLow = 0, hhcGoalHigh = 0; // Load values from front end Map map = new HashMap();
was wrongly formatted as
int hhcGoalLow = 0, hhcGoalHigh = 0; // Load values from front end Map map = new HashMap();
Now it does (depending on the code convention)
int hhcGoalLow = 0, hhcGoalHigh = 0; // Load values from front end Map map = new HashMap();
Creator calls that appeared after left parenthesis were not always correctly wrapped and could exceed the maximal line length
|
System.out.println(new Runnable() {
}); |
Now it does (depending on the code convention)
|
System.out.println( |
new Runnable() { |
}); |
if
, while
, switch
and
synchronized
statements could lead to a crossing of the
maximal line length when using Sun brace style
|
if (isFeatureSelected(data, Keys.IMPORT_SETTINGS)) {
} |
Was printed as
|
if (isFeatureSelected(data, Keys.IMPORT_SETTINGS)) {
} |
Now it does (depending on the code convention)
|
if (isFeatureSelected(data, |
Keys.IMPORT_SETTINGS)) { |
} |
Method calls used as last expression in if
,
while
, switch
and
synchronized
statements could lead to a crossing of the
maximal line length. Naturally, this only happened when using C brace style or
for statements without brace blocks
|
if (isFeatureSelected(data, Keys.IMPORT_SETTINGS))
takeAction(); |
|
Was printed as
|
if (isFeatureSelected(data, Keys.IMPORT_SETTINGS))
takeAction(); |
Now it does (depending on the code convention)
|
if (isFeatureSelected(data, |
Keys.IMPORT_SETTINGS)) |
takeAction(); |
Expressions after a return statement could exceed the maximal line length. Depending on the settings,
| return (isInterface() ? "interface " : (isPrimitive() ? "" : "class ")) + getName(); |
was formatted as
| return (isInterface() ? "interface " : (isPrimitive() ? "" : "class ")) + getName(); | |
Now it does (depending on the code convention)
| return | (isInterface() ? "interface " : (isPrimitive() ? "" : "class ")) + | getName(); | |
Expressions enclosed with parentheses lead to unncessary wrapping in some cases.
| if ((crNodeText == null) || (rNodeText.getData().trim().length() == 0)) | ; | | if ((ccrNodeText == null) || (rNodeText.getData().trim().length() == 0))| ; |
Was wrongly printed as
| if ((crNodeText == null) || | (rNodeText.getData().trim().length() == 0)) | ; | | if ((ccrNodeText == null) || | (rNodeText.getData().trim().length() == 0)) | ; |
Now it does (depending on the code convention)
| if ((crNodeText == null) || (rNodeText.getData().trim().length() == 0)) | ; | | if ((ccrNodeText == null) || (rNodeText.getData().trim().length() == 0))| ; |
Chained method calls were not wrapped at a lower level (along the dots) after assignments and parentheses
| longMethodName(one().two().three()); value = one().two().three(); |
Was printed as
| longMethodName( | one().two().three()); value = | one().two().three();| |
even if "Always wrap when exceed left parenthesis" and/or "Always wrap when exceed after assignments" were disabled. Now it respects the settings and if they are disabled, it does
| longMethodName(one() | .two().three()); | value = one().two() | .three(); | |
Assignment aligning could fail when an assignment expression span several lines.
ViewEvent event = new ViewEvent(this, MEDEA_TOURENBERICHT, ViewEvent.SEARCH); OrgeinheitVO gewaehlteOrg = getOrgAuswahl().getSelectedOrg();
was wrongly printed as
ViewEvent event = new ViewEvent(this, MEDEA_TOURENBERICHT, ViewEvent.SEARCH); OrgeinheitVO gewaehlteOrg = getOrgAuswahl().getSelectedOrg();
Now it does (depending on the code convention)
ViewEvent event = new ViewEvent(this, MEDEA_TOURENBERICHT, ViewEvent.SEARCH); OrgeinheitVO gewaehlteOrg = getOrgAuswahl().getSelectedOrg();
Formatting interfaces could lead to unexpected results when no import declarations were contained: the setting for blank lines after the package statement was ignored, and always one blank line printed between package and interface declaration statement.
package org.jboss.nukes.addons.modules.news.model; public interface Story { }
Was wrongly printed
package org.jboss.nukes.addons.modules.news.model; public interface Story { }
Now it does (depending on the code convention)
package org.jboss.nukes.addons.modules.news.model; public interface Story { }
Javadoc comments that only contained a single @todo
tag
(i.e. no description section) were wrongly printed when the comment appeared
before a valid code element
/** * @todo move into separate helper class because similar code is used in * Foo.java */ int querySettings() { }
was wrongly printed as
/** * @todo move into separate helper class because similar code is used in * Foo.java */ int querySettings() { }
Now it does (depending on the code convention)
/** * @todo move into separate helper class because similar code is used in * InstallHandler.java */ int querySettings() {}
With "Spaces within method calls" enabled,
spaces were wrongly printed within constructor calls
(this()
and super()
).
ActiveTestSuite.super( test, result );
was wrongly printed as
ActiveTestSuite.super( test, result );
^^
Now it does (depending on the code convention)
ActiveTestSuite.super( test, result );
With both "Spaces within method calls" and "Wrap always when exceed after left parenthesis" enabled, a trailing blank space was printed after the left parenthesis upon wrapping
super(¶ "The specified assembly is not the event's main" +¶ " inventory or its sub-assemly.");¶
was wrongly printed as
super( ¶ "The specified assembly is not the event's main" +¶ " inventory or its sub-assemly.");¶
Now it does (depending on the code convention)
super(¶ "The specified assembly is not the event's main" +¶ " inventory or its sub-assemly.");¶
With the "Check HTML tags" option enabled, Javadoc comments that appeared at invalid positions (not before package, class, interface, constructor, method and field declarations) were incorrectly modified
public void foo() { /** * multi line comment test 2 * multi line comment test 2 */ }
was wrongly printed as
public void foo() { /** multi line comment test 2 multi line comment test 2 */ }
Now it does (depending on the code convention)
public void foo() { /** * multi line comment test 2 * multi line comment test 2 */ }
No line break was printed before <th> tags
/**
* <table>
* <tr>
* <th>Name</th>
* </tr>
*
* <tr>
* <td>John Doo</td>
* </tr>
* </table>
*/
Was wrongly printed as
/**
* <table>
* <tr><th>Name</th>
* </tr>
*
* <tr>
* <td>John Doo</td>
* </tr>
* </table>
*/
Now it does (depending on your settings)
/**
* <table>
* <tr>
* <th>Name</th>
* </tr>
*
* <tr>
* <td>John Doo</td>
* </tr>
* </table>
*/