tags:

views:

25

answers:

2

I'm trying to use the Eclipse Java Code formatter. Eclipse 3.5 on Red Hat Linux.

I have found the Code Styles at Preferences / Java / Code Style / Formatter.

I have created a new profile

Our team uses c++ style braces, so I have specified those. They display in the preview nicely:

   SomeClass fField = new SomeClass()
    {
    };

I am struggling with the Line Wrapping facility. I wish to have the majority of listed elements set to "Wrap all elements, every element on a new line" My max line width is 80, both indentations are set to '1' and Never Join Lines is not ticked. The preview gives me the desired look, e.g. Function Calls / Arguments:

class Example
{
    void foo()
    {
        Other.bar(
            100,
            200,
            300,
            400,
            500,
            600,
            700,
            800,
            900);
    }
}

However, when I apply the format to actual source code,(Select All -> Source -> Format) the parameters are collapsed onto one line.

class Example
{
    void foo()
    {
        Other.bar(
            100,
            200,
            300,
            400,
            500,
            600,
            700,
            800,
            900);
    }
}

becomes

class Example
{
    void foo()
    {
        Other.bar(100, 200, 300, 400, 500, 600, 700, 800, 900);
    }
}

I know the formatter is partially working, because it correctly sorts out my brace requirements.

I have tried configuring my Format profile to be both project specific, and to apply generally with the same results.

Is there a gotcha that would prevent the Code Formatter applying Line Wrapping, but still apply other formats?

In several years of development this is my first "Wah, I need help! request", as I've been bashing my head for a while...

Thanks

A: 

There are a lots of bugs related to wrapping, fixed in 3.6:

So:

  1. Some of those bugs can give you an idea of the right setting to put for this kind of formatting
  2. Could you check if you reproduce the issue with an eclipse 3.6? (even though you might not want to migrate to an Eclipse3.6 in your current project: this is just for testing purposes)

If that persists, then it is a good candidate for a bug report about formatter.

VonC