Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » question on ugly code formatting
question on ugly code formatting [message #670971] Mon, 16 May 2011 12:33 Go to next message
Ed Guenter is currently offline Ed GuenterFriend
Messages: 6
Registered: February 2010
Junior Member
Hello there,

In our code base we do tracing like this:

if (Trace.TRACE_LEVELX)
    Trace
             .trace(
                      TRACE_MASKX,
                      id
                             + ": ERROR - and here comes some pretty extensive long string that you dont need to see I guess");


To be precise: we do tracing like that. The ugly formatting is introduced by
eclipse. I tried various code formatters, like the built-in eclipse or "java"; but also external ones like for android. Didnt help.

Any idea which setting I need to touch to get this any "nicer", like this here for example:

if (Trace.TRACE_LEVELX)
    Trace.trace(TRACE_MASKX,
                id + ": ERROR - and here comes some pretty extensive long string that you dont need to see I guess");

Re: question on ugly code formatting [message #671067 is a reply to message #670971] Mon, 16 May 2011 16:47 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 545
Registered: July 2009
Senior Member
Preferences > Java > Code Style > Formatter
- Click 'Edit'
- Go to Line wrapping tab
- Play around with Line wrapping policy for 'function calls'
- You might also have to uncheck 'Never join already wrapped lines' option
Re: question on ugly code formatting [message #671518 is a reply to message #671067] Wed, 18 May 2011 07:58 Go to previous messageGo to next message
Ed Guenter is currently offline Ed GuenterFriend
Messages: 6
Registered: February 2010
Junior Member
I played around in that corner - unfortunately no luck at all.

Then I ran jacobe on command line; that tool works better for our trace statements, but it does many other things not the way I want them (and I am not sure if i want to develop my own control file for that tool).

Confused
Re: question on ugly code formatting [message #671578 is a reply to message #671518] Wed, 18 May 2011 11:41 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 545
Registered: July 2009
Senior Member
On 5/18/2011 1:28 PM, Ed Guenter wrote:
> I played around in that corner - unfortunately no luck at
> all.
Strange. Which version of Eclipse are you using ? Can you give detailed
steps ?

It works for me when I set the Line wrapping policy for function calls
to 'Do not wrap' and uncheck 'Never join already wrapped lines' option,
and then format your code.
Re: question on ugly code formatting [message #671844 is a reply to message #671578] Thu, 19 May 2011 07:20 Go to previous messageGo to next message
Ed Guenter is currently offline Ed GuenterFriend
Messages: 6
Registered: February 2010
Junior Member
Deepak Azad wrote on Wed, 18 May 2011 07:41

It works for me when I set the Line wrapping policy for function calls
to 'Do not wrap' and uncheck 'Never join already wrapped lines' option,
and then format your code.


You are correct; I wasn't careful enough with my latest experiments.
With the settings that you describe, the trace statements are not wrapped.

But unfortunately, no calls are wrapped any more. Leaves me with
statements well beyond column count 300 or so.

I guess I will investigate in a different direction - defining settings that work "good enough" for most of our code; and manually tweak those lines that dont work.
(like shortening up the string messages that we trace).

Thank you very much for your help.
Re: question on ugly code formatting [message #671861 is a reply to message #671844] Thu, 19 May 2011 08:03 Go to previous message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 545
Registered: July 2009
Senior Member
On 5/19/2011 12:50 PM, Ed Guenter wrote:
> I guess I will investigate in a different direction - defining settings
> that work "good enough" for most of our code; and manually tweak those
> lines that dont work.
> (like shortening up the string messages that we trace).

Setting the policy to 'Wrap where necessary' should do the job.
Previous Topic:Libraries - can this be done?
Next Topic:Remote Development
Goto Forum:
  


Current Time: Sun Dec 21 05:35:49 GMT 2014

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

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