Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Code formatter
Code formatter [message #218686] Fri, 11 November 2005 05:14 Go to next message
Eclipse UserFriend
Hi,

I am looking for an option in the code formatter which inserts braces and
line breaks in the following situation:

if (x == 1) return 5;

The result should look like this:

if (x == 1) {
return 5;
}

Searching the help did not get me on with this. Could someone please help
me, if there is an option or what else I can do?

Thanks
Michael
Re: Code formatter [message #218693 is a reply to message #218686] Fri, 11 November 2005 05:47 Go to previous messageGo to next message
Eclipse UserFriend
Michael Hausl wrote:

> if (x == 1) return 5;
>
> The result should look like this:
>
> if (x == 1) {
> return 5;
> }

I searched, but wasnt able to find it too.

In case it is not possible yet: I would like to have this too.


---
Mario
Re: Code formatter [message #218701 is a reply to message #218686] Fri, 11 November 2005 06:15 Go to previous messageGo to next message
Eclipse UserFriend
Michael Hausl wrote:
> Hi,
>
> I am looking for an option in the code formatter which inserts braces and
> line breaks in the following situation:
>
> if (x == 1) return 5;
>
> The result should look like this:
>
> if (x == 1) {
> return 5;
> }

This goes beyond formatting (formatting only rearranges whitespace). It
would be good item for the new "Clean up" wizard (see Source>Clean up).

-tom
Re: Code formatter [message #218707 is a reply to message #218693] Fri, 11 November 2005 07:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

Mario Ivankovits wrote:

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537

I have separate plugin that allows add/remove () and {}. In reallity
I already can not live without it. :-)

However I don't like idea that it should be accessible only from
"Clean Up" wizard, because this will have it too heavy. Just separate
action "Change code style", same as "Organize imports" or "Format" is
better IMHO. It can be in "Clean Up", but we need also something easy to
invoke. I press Organize_imports/Change_code_style(my)/Format every
several seconds. :-)


> Michael Hausl wrote:
>
>> if (x == 1) return 5;
>>
>> The result should look like this:
>>
>> if (x == 1) {
>> return 5;
>> }
>
>
> I searched, but wasnt able to find it too.
>
> In case it is not possible yet: I would like to have this too.
Re: Code formatter [message #218729 is a reply to message #218707] Fri, 11 November 2005 08:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: radoslawg.xxxx.xx

Konstantin Scheglov napisał(a):
> Mario Ivankovits wrote:
>
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537
>
> I have separate plugin that allows add/remove () and {}. In reallity I
> already can not live without it. :-)

Could you share it? I have checkstyle set to enforce this but I often
forget about it and have to do it manually. Also my old java files hurt
because of it and I have a lot of legacy code to uplift.

Cheers,
Radek.
Re: Code formatter [message #218736 is a reply to message #218707] Fri, 11 November 2005 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benno_baumgartner.ch.ibm.com

Hi

I could provide a "light" clean up wich does execute the clean ups on the
current cu without showing a dialog/preview. If this is what you want? The
clean ups would be those which have been selected last time in the wizard or
maybe in a preference page.

Regards
Benno

"Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
news:dl224a$4n5$1@news.eclipse.org...
> Mario Ivankovits wrote:
>
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537
>
> I have separate plugin that allows add/remove () and {}. In reallity I
> already can not live without it. :-)
>
> However I don't like idea that it should be accessible only from "Clean
> Up" wizard, because this will have it too heavy. Just separate action
> "Change code style", same as "Organize imports" or "Format" is better
> IMHO. It can be in "Clean Up", but we need also something easy to invoke.
> I press Organize_imports/Change_code_style(my)/Format every several
> seconds. :-)
>
>
>> Michael Hausl wrote:
>>
>>> if (x == 1) return 5;
>>>
>>> The result should look like this:
>>>
>>> if (x == 1) {
>>> return 5;
>>> }
>>
>>
>> I searched, but wasnt able to find it too.
>>
>> In case it is not possible yet: I would like to have this too.
Re: Code formatter [message #218743 is a reply to message #218736] Fri, 11 November 2005 11:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

Benno Baumgartner wrote:

Exactly. I need just apply changes, without any
questions/dialogs/wizards, I know what I have configured and need to apply
styling only for unit that I currently change.

Show wizard and then press "Finish", as you suggested in bug report, is
not fast enough. :-) "Light" version would be great.

If settings in wizard are per-project it is enough to apply last
selected clean ups. If not, I think that per-project preference page is
better, like JDT supports not project specific formatting settings.


> I could provide a "light" clean up wich does execute the clean ups on the
> current cu without showing a dialog/preview. If this is what you want? The
> clean ups would be those which have been selected last time in the wizard or
> maybe in a preference page.

> Regards
> Benno

> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
> news:dl224a$4n5$1@news.eclipse.org...
>> Mario Ivankovits wrote:
>>
>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537
>>
>> I have separate plugin that allows add/remove () and {}. In reallity I
>> already can not live without it. :-)
>>
>> However I don't like idea that it should be accessible only from "Clean
>> Up" wizard, because this will have it too heavy. Just separate action
>> "Change code style", same as "Organize imports" or "Format" is better
>> IMHO. It can be in "Clean Up", but we need also something easy to invoke.
>> I press Organize_imports/Change_code_style(my)/Format every several
>> seconds. :-)
>>
>>
>>> Michael Hausl wrote:
>>>
>>>> if (x == 1) return 5;
>>>>
>>>> The result should look like this:
>>>>
>>>> if (x == 1) {
>>>> return 5;
>>>> }
>>>
>>>
>>> I searched, but wasnt able to find it too.
>>>
>>> In case it is not possible yet: I would like to have this too.
Re: Code formatter [message #218750 is a reply to message #218729] Fri, 11 November 2005 11:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

Radoslaw Grzanka wrote:

>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537
>>
>> I have separate plugin that allows add/remove () and {}. In reallity I
>> already can not live without it. :-)

> Could you share it? I have checkstyle set to enforce this but I often
> forget about it and have to do it manually. Also my old java files hurt
> because of it and I have a lot of legacy code to uplift.

See this bug report. I've just uploaded my plugin as temporary solution
for users that need such code transformations and we all wait better
solution from Benno. :-)
Re: Code formatter [message #218782 is a reply to message #218750] Fri, 11 November 2005 16:55 Go to previous message
Eclipse UserFriend
Originally posted by: radoslawg.xxxx.xx

Konstantin Scheglov napisał(a):
> Radoslaw Grzanka wrote:
>
>>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=87537

> See this bug report. I've just uploaded my plugin as temporary solution
> for users that need such code transformations and we all wait better
> solution from Benno. :-)
>
>

Thank you so much.

Radek
Previous Topic:Eclipse 3.1 and ANT script
Next Topic:Jar creation errors
Goto Forum:
  


Current Time: Fri May 09 02:23:48 EDT 2025

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

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

Back to the top