Share

Jalopy Java Source Code Formatter

Tracker: Bugs

5 enum formatting munges whitespace - ID: 1339021
Last Update: Settings changed ( notzippy )

Given the following source with 1.5b3:

public final class HttpRequest
{
public enum Method
{
/** Data is encoded in the query. */
GET,

/** Data is encoded in the body. */
POST
}
}

and the command line:

jalopy.sh -d _new JalopyTest.java

I get back (also attached):

public final class HttpRequest {
public enum Method {/** Data is encoded in the
query. */
GET,

/** Data is encoded in the body. */
POST;
}
}

Note that there is now a trailing space after "GET," and
that the GET comment has been glued to the previous
line's {.


Adam Zell ( zellster ) - 2005-10-26 23:43

5

Closed

Fixed

S

Core

1.5b5

Public


Comments ( 7 )

Date: 2005-11-28 18:49
Sender: notzippyAccepting Donations

Logged In: YES
user_id=723231

Fixed, There wont be any control on this setting for the
time being though.


Date: 2005-11-21 23:37
Sender: zellster

Logged In: YES
user_id=152749

I have made the suggested printing change, which removes the
unwanted trailing space after the first enum element.

I still have "POST;}" on the last line, when I would prefer
that the closing "}" be on a separate line. Is there
another setting I can change?

Thanks.



Date: 2005-11-21 19:24
Sender: notzippyAccepting Donations

Logged In: YES
user_id=723231

ok the issue (now) is in your printer settings.
Goto printer->wrapping->misc. Change Enumerations->Left
brace starts new line wrap after (change to) "1" (the
default is 3).
This will supress the blank space. Of course all enums
constants will now start a new line also.

I will leave this open though since it should behave
properly without modifying that setting.

Z



Date: 2005-11-19 08:18
Sender: zellster

Logged In: YES
user_id=152749

The same behavior occurs with 1.5b5:

public enum Method
{
/**
* Data is encoded in the query.
*/
GET,
/**
* Data is encoded in the body.
*/
POST;}

Note that the first "{" now retains its position, but the
trailing space following "GET," remains as does the "}"
immediately following "POST;".

Lastly, what is the policy for whitespace between enum
elements? The original source had a newline between "GET"
and "POST" which was removed by jalopy.

Jalopy-processed source attached. Thanks for the great tool
and support.




Date: 2005-11-14 19:15
Sender: notzippyAccepting Donations

Logged In: YES
user_id=723231

While printing the enumeration block the enum constant
printer now checks to see if a new line is being printed
after the enum constant. If this is true then no space is
printed following the commas (regardless of the white space
setting for commas).




Date: 2005-11-07 23:43
Sender: zellster

Logged In: YES
user_id=152749

Just to clarify, is the following behavior intended:

"GET, " <-- Note the trailing space after the comma to end
of line

This is the only instance I have seen so far where Jalopy
will insert whitespace before the end of line. The
resulting regex of '[ \t]+$' causes tools such as
Checkstyle to complain.

Thanks.



Date: 2005-11-07 19:01
Sender: notzippyAccepting Donations

Logged In: YES
user_id=723231

The trailing space is correct (If you have specified 1 blank
line for javadoc comments (See blank lines))

All javadoc and sperator comments will now start on there
own line



Attached Files ( 2 )

Filename Description Download
JalopyTest.java Download
JalopyTest.java Processed source file Download

Changes ( 19 )

Field Old Value Date By
close_date 2005-11-28 18:49 2005-12-19 20:45 notzippy
status_id Pending 2005-12-19 20:45 notzippy
status_id Open 2005-11-28 18:49 notzippy
close_date - 2005-11-28 18:49 notzippy
resolution_id None 2005-11-28 18:49 notzippy
status_id Closed 2005-11-19 08:18 zellster
resolution_id Fixed 2005-11-19 08:18 zellster
artifact_group_id 1.5rc1 2005-11-19 08:18 zellster
close_date 2005-11-14 19:15 2005-11-19 08:18 zellster
File Added 156849: JalopyTest.java 2005-11-19 08:18 zellster
close_date - 2005-11-14 19:15 notzippy
status_id Open 2005-11-14 19:15 notzippy
close_date 2005-11-07 19:01 2005-11-07 23:43 zellster
status_id Pending 2005-11-07 23:43 zellster
assigned_to nobody 2005-11-07 19:08 notzippy
close_date - 2005-11-07 19:01 notzippy
resolution_id None 2005-11-07 19:01 notzippy
status_id Open 2005-11-07 19:01 notzippy
File Added 153918: JalopyTest.java 2005-10-26 23:43 zellster