Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Force "same line" on curly braces in Eclipse formatter - not working
Force "same line" on curly braces in Eclipse formatter - not working [message #742310] Thu, 20 October 2011 11:31 Go to next message
ilfrin  is currently offline ilfrin Friend
Messages: 3
Registered: October 2011
Junior Member
I have posted this yesterday on stackoverflow, but haven't received any answers, so I'm not sure if the question is so dumb or so hard? Smile

In my java code formatter, in my profile I have (actually it's the eclipse's default) all choices in the "braces" tab set to "same line". Nevertheless when I have a piece of code like this:
interface TestI
    {
}

and I invoke the formatter (key binding, context menu, whatever) all I get is
interface TestI
{
}

it doesn't move the opening braces to the same line, the same applies to methods, control statements etc. then when I manually change it to
interface TestI      {
}

it then formats it to:
interface TestI {
}

So it generally respects the "braces format" I chose manually and only reformats the spaces between the braces and other elements.

Other formatting options in my formatter work as specified. I'm using the latest Eclipse Indigo release 3.7.1, I had the same with 3.7, and my friend tried it with a 3.5 release, so it makes me think that this is on purpose, but then again why is there this "braces" tab at all if I can't reformat the code using this rule ...

And what's even more weird is that when I set the rule not to "same line" but "next line" then formatting works as expected, it forces the rule regardless of how I've written the code, as soon as I change it back to "same line" the the formatter doesn't force this rule.

I hope I'm missing something that's right there and that you will make me feel stupid in a moment and the problem will go away Razz ... I have a gazillion of classes to cleanup and I don't want to do it by hand .. Smile

[Updated on: Thu, 20 October 2011 11:56]

Report message to a moderator

Re: Force "same line" on curly braces in Eclipse formatter - not working [message #743076 is a reply to message #742310] Fri, 21 October 2011 05:07 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
I am not able to reproduce this behavior on 3.7.1 with the default profile(s). If you are using a modified profile, please attach your profile so that I can look at.
Re: Force "same line" on curly braces in Eclipse formatter - not working [message #743290 is a reply to message #743076] Fri, 21 October 2011 10:07 Go to previous messageGo to next message
ilfrin  is currently offline ilfrin Friend
Messages: 3
Registered: October 2011
Junior Member
Hmmm, thank you Satyam for help, you pointed me to the right direction, when I revert to the default formatter, when it works, but still I fail to see any setting that could have messed that up, I'm attaching the exported format. I have exported this format from a previously used Ecipse 3.6 installation, as I recall it worked well then.

Do you see anything there that could have caused it?
  • Attachment: ef.xml
    (Size: 30.15KB, Downloaded 360 times)
Re: Force "same line" on curly braces in Eclipse formatter - not working [message #743302 is a reply to message #743290] Fri, 21 October 2011 10:27 Go to previous message
ilfrin  is currently offline ilfrin Friend
Messages: 3
Registered: October 2011
Junior Member
Found it... it was caused by:
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
which in the Formatter setting GUI is under "Line Wrapping/Never join already wrapped lines"

yes now I remember setting it, but I never thought that this would override the braces setting ...

a nice-to-have feature would be to have warnings if you set options that are no-ops because of other options that you've set override them

Again thanks for pointing me to the right direction.

Case closed.
Previous Topic:Connecting to Sql
Next Topic:comments being removed from web.xml when I create a new servlet
Goto Forum:
  


Current Time: Wed May 08 07:32:35 GMT 2024

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

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

Back to the top