Set "same line" to curly braces in Eclipse formatter

In my formatting of java code in my profile I have (in fact, this is the default eclipse), all the options on the tab “brackets” are set to “one line”. However, when I have a code like this:

interface TestI { } 

and I call the formatter (key binding, context menu, whatever), all I get is

 interface TestI { } 

it does not move the opening curly braces to the same line, the same applies to methods, control operators, etc., when I manually change it to

 interface TestI { } 

then formats it:

 interface TestI { } 

Thus, he generally respects the format that I did manually, but only formats the spaces between curly braces and other elements.

Other formatting options in my text file work as directed. I use the latest version of Eclipse Indigo 3.7.1, I had the same thing with 3.7, and my friend tried it with the release of 3.5, so it seems to me that this is special, but again, why are these “brackets” in general, if I cannot reformat the code using this rule ...

Hope I have something missing and you make me fall stupid and the problem goes away because I have a class to clean up and I don't want to do it manually. :)

UPDATE: when I set the rule not on the “same line”, but on the “next line”, the formatting works as expected, it forces the rule no matter how I wrote the code, as soon as I get it back to “in that the same line, the formatter does not force this rule.

+6
source share
1 answer

Found ... this was caused by:

 <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/> 

which, in the Formatter parameter setting, is located in the section "Wrapping Rows / Never Join Already Wrapped Rows"

yes, now I remember how I installed it, but I never thought that it would change the curly braces setting ...

A nice feature of formatting will be to have warnings if you set parameters that are not operations, because of other options that you set, override them.

+13
source

Source: https://habr.com/ru/post/899602/


All Articles