Skip to main content



      Home
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 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #165583 is a reply to message #162994] Mon, 14 August 2006 11:35 Go to previous messageGo to next message
Eclipse UserFriend
Hendrik Maryns a écrit :
> I’ve been annoyed by this too. File a bug: bugs.eclipse.com/bugs
This is something we want to improve. No need to open a new bug. There
is already an existing bug for this issue.
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=59891
--
Olivier
Re: Source Formatter Behavior With Chain Style Statement [message #201132 is a reply to message #162977] Thu, 22 March 2007 11:51 Go to previous message
Eclipse UserFriend
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 :-)
Previous Topic:Looking for Simple Eclipse-WTP JSP Tutorial
Next Topic:Variable-Name Highlighting
Goto Forum:
  


Current Time: Tue Jun 03 05:04:51 EDT 2025

Powered by FUDForum. Page generated in 0.09961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top