Home » Newcomers » Newcomers » Source Formatter Behavior With Chain Style Statement
Source Formatter Behavior With Chain Style Statement [message #162977] |
Mon, 31 July 2006 22:37  |
Eclipse User |
|
|
|
In one of my projects, I'd use apache commons-lang library to generate
toString() method, like this:
return new ToStringBuilder( this )
.append( "name", getName() )
.append( "category", getCategory() )
.append( "download", getDownloadUrl() )
.append( "detail", getDetailUrl() )
.append( "publisher", getPublisher() )
.append( "time", getPublishTime() )
.append( "users", getUsers() )
.toString();
Each method is on a new line. This style is clear to me.
But when using Eclipse to format this code, it is formatted into this
ugly like:
return new ToStringBuilder( this ).append( "name", getName() ).append(
"category", getCategory() ).append( "download", getDownloadUrl() )
..append( "detail", getDetailUrl() ).append( "publisher",
getPublisher() ).append( "time", getPublishTime() ).append(
"seeds", getSeeds() ).append( "users", getUsers() ).toString();
I studied preferences -> Java -> Code Style -> Formatter page, but could
not find anything that could put each chain-style method call on a new
line.
Is there any solution?
|
|
|
Re: Source Formatter Behavior With Chain Style Statement [message #162994 is a reply to message #162977] |
Tue, 01 August 2006 04:22   |
Eclipse User |
|
|
|
Originally posted by: hendrik_maryns.despammed.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
yuhao schreef:
> In one of my projects, I'd use apache commons-lang library to generate
> toString() method, like this:
>
> return new ToStringBuilder( this )
> .append( "name", getName() )
> .append( "category", getCategory() )
> .append( "download", getDownloadUrl() )
> .append( "detail", getDetailUrl() )
> .append( "publisher", getPublisher() )
> .append( "time", getPublishTime() )
> .append( "users", getUsers() )
> .toString();
>
> Each method is on a new line. This style is clear to me.
>
> But when using Eclipse to format this code, it is formatted into this
> ugly like:
>
> return new ToStringBuilder( this ).append( "name", getName() ).append(
> "category", getCategory() ).append( "download", getDownloadUrl() )
> .append( "detail", getDetailUrl() ).append( "publisher",
> getPublisher() ).append( "time", getPublishTime() ).append(
> "seeds", getSeeds() ).append( "users", getUsers() ).toString();
>
> I studied preferences -> Java -> Code Style -> Formatter page, but could
> not find anything that could put each chain-style method call on a new
> line.
>
> Is there any solution?
I’ve been annoyed by this too. File a bug: bugs.eclipse.com/bugs
H.
- --
Hendrik Maryns
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFEzw9Je+7xMGD3itQRAiF+AJ0XIIBojWxv3LusWlY3Fun1VgyoVACb BW+Z
gW0cv/jX0SQX/bL2nYP6w4I=
=GvIi
-----END PGP SIGNATURE-----
|
|
| |
Re: Source Formatter Behavior With Chain Style Statement [message #201132 is a reply to message #162977] |
Thu, 22 March 2007 11:51  |
Eclipse User |
|
|
|
Originally posted by: nowhere.a.com
yuhao wrote :
> In one of my projects, I'd use apache commons-lang library to generate
> toString() method, like this:
>
> return new ToStringBuilder( this )
> .append( "name", getName() )
> .append( "category", getCategory() )
> .append( "download", getDownloadUrl() )
> .append( "detail", getDetailUrl() )
> .append( "publisher", getPublisher() )
> .append( "time", getPublishTime() )
> .append( "users", getUsers() )
> .toString();
>
> Each method is on a new line. This style is clear to me.
>
> But when using Eclipse to format this code, it is formatted into this
> ugly like:
>
> return new ToStringBuilder( this ).append( "name", getName() ).append(
> "category", getCategory() ).append( "download", getDownloadUrl() )
> .append( "detail", getDetailUrl() ).append( "publisher",
> getPublisher() ).append( "time", getPublishTime() ).append(
> "seeds", getSeeds() ).append( "users", getUsers() ).toString();
>
> I studied preferences -> Java -> Code Style -> Formatter page, but could
> not find anything that could put each chain-style method call on a new
> line.
>
> Is there any solution?
Just found a workaround. Simply place a comment after each line:
return new ToStringBuilder( this ) //
.append( "name", getName() ) //
.append( "category", getCategory() ) //
.append( "download", getDownloadUrl() ) //
.append( "detail", getDetailUrl() ) //
.append( "publisher", getPublisher() ) //
.append( "time", getPublishTime() ) //
.append( "users", getUsers() ) //
.toString(); //
This works in parameter lists, enums, etc
--
Wojtek :-)
|
|
|
Goto Forum:
Current Time: Tue Jun 03 05:04:51 EDT 2025
Powered by FUDForum. Page generated in 0.09961 seconds
|