Home » Language IDEs » Java Development Tools (JDT) » Jave 3.3 code formatter question
Jave 3.3 code formatter question [message #246284] |
Fri, 27 July 2007 16:04  |
Eclipse User |
|
|
|
Hi all,
I would like to invoke the code formatter when I save a file, but I'm
running into one annoyance I can't seem to work around. I want to
format method parameters manually, e.g.
void myMethod(int a, int b,
int c, double d) {
....
}
but Eclipse 3.3 won't let me. If I have the formatter on, it insists on
unwrapping the declaration to
void myMethod(int a, int b, int c, double d) {
....
}
and rewrapping if that violates the line length. This is with the
relevant formatter preference set to no wrapping; any of the other
wrapping options wraps it differently, but not the way I want.
The smart money says I'm missing something. Is there a way to tell the
code formatter to ignore parameter lists when formatting the code, or a
way to insert a "hard" line break that is inviolable?
TIA,
Paul
|
|
|
Re: Jave 3.3 code formatter question [message #246369 is a reply to message #246284] |
Mon, 30 July 2007 16:54   |
Eclipse User |
|
|
|
Originally posted by: jacek.pospychala.pl.ibm.com
hi Paul,
sorry, currently there is no way to do what you want. Would you agree
with me, that formatting you'd like to have is very specific? I wonder
what should be a more general rule, that would fit your needs.
Regarding inserting "hard" line break. Where would you actually expect
it? After 29th column, after 2 argument, after second "," in line?
Maybe it would be better to select certain types of source code (like
method declarations), that should not be formatted.
I'd say, that you could raise an enhancement request here
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT& component=Text
however keep in mind, that there are also voices, that formatter is
already too difficult to configure because of huge number of options it
offers.
Paul A. Rubin wrote:
> Hi all,
>
> I would like to invoke the code formatter when I save a file, but I'm
> running into one annoyance I can't seem to work around. I want to
> format method parameters manually, e.g.
>
> void myMethod(int a, int b,
> int c, double d) {
> ...
> }
>
> but Eclipse 3.3 won't let me. If I have the formatter on, it insists
> on unwrapping the declaration to
>
> void myMethod(int a, int b, int c, double d) {
> ...
> }
>
> and rewrapping if that violates the line length. This is with the
> relevant formatter preference set to no wrapping; any of the other
> wrapping options wraps it differently, but not the way I want.
>
> The smart money says I'm missing something. Is there a way to tell
> the code formatter to ignore parameter lists when formatting the code,
> or a way to insert a "hard" line break that is inviolable?
>
> TIA,
> Paul
|
|
|
Re: Jave 3.3 code formatter question [message #246384 is a reply to message #246369] |
Mon, 30 July 2007 19:47   |
Eclipse User |
|
|
|
Hi Jacek,
Jacek Pospychala wrote:
> hi Paul,
> sorry, currently there is no way to do what you want. Would you agree
> with me, that formatting you'd like to have is very specific?
Yes -- definitely a matter of personal taste, and my taste may be out of
the mainstream.
> I wonder what should be a more general rule, that would fit your needs.
> Regarding inserting "hard" line break. Where would you actually expect
> it? After 29th column, after 2 argument, after second "," in line?
I was thinking that it would be entered manually. For instance, in some
word processors ctrl-enter means "break the line and don't alter that
when you reflow the text". So perhaps ctrl-enter here could mean "line
break not to be altered during a reformat".
> Maybe it would be better to select certain types of source code (like
> method declarations), that should not be formatted.
That would work, but I suppose the list of things to opt into/out of
formatting could get rather long.
> I'd say, that you could raise an enhancement request here
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT& component=Text
> however keep in mind, that there are also voices, that formatter is
> already too difficult to configure because of huge number of options it
> offers.
I'm sympathetic to that, having just gone through configuration of the
formatter. Perhaps I'll suggest ctrl-enter as a possibility; it doesn't
require another setting.
Thanks,
Paul
|
|
| | | |
Re: Jave 3.3 code formatter question [message #246823 is a reply to message #246492] |
Tue, 14 August 2007 14:11  |
Eclipse User |
|
|
|
Walter Harley wrote:
>> I'm not sure if it's related to another cosmic annoyance. In the
>> Formatter -> Comments tab, I've unchecked everything. I even exited and
>> did a -clean restart to make sure this was absorbed. Nonetheless,
>>
>> double xyz; // comment 1
>> double abcdefg; // comment 2
>>
>> turns into
>>
>> double xyz; // comment 1
>> double abcdefg; // comment 2
>>
>> after a save. I even tried turning off the option to clean up end-of-line
>> whitespace. Didn't help.
>
> Huh, that seems very peculiar that you would be getting formatting on save
> with your formatting options turned off. That sure sounds like there's
> still something turned on. Make sure you don't have some sort of workspace
> setting interfering, or some kind of autoformatting plug-in (possibly
> associated with your version control system?) present.
>
Sorry, meant to finish this thread of sooner but got side-tracked. I
only have one workspace (and I'm tweaking settings at the workspace
level), I don't have any project-specific settings, I don't have any
plug-ins beyond what came with Europa, and I don't have a VCS (I'm a one
man band). Beyond Mylyn, whose precise function I don't know (but which
doesn't seem to be the culprit here), I don't know why I had so much
trouble controlling formatting.
Ultimately, though, I turned off code formatting in the clean-up
function. It's a nice feature, but I lived without it before.
Thanks,
Paul
|
|
|
Goto Forum:
Current Time: Mon Jun 23 16:07:50 EDT 2025
Powered by FUDForum. Page generated in 0.05021 seconds
|