Skip to main content



      Home
Home » Newcomers » Newcomers » Array braces formatting(Problems with indenting of array initializer braces)
Array braces formatting [message #1439850] Tue, 07 October 2014 11:41 Go to next message
Eclipse UserFriend
I'm have trouble with the settings of the Eclipse formatter (Java ID on OSX 10.9.5). I want a simple array to look like this:

Foo myFoo[] =
{
    foo1,
    foo2,
    foo3
};


but instead I get this:

Foo myFoo[] =
            {
    foo1,
    foo2,
    foo3
            };

I found a discussion about formatting multi-dimensional arrays, and followed their formatting suggestions as their arrays looked like what I want, but I can't figure out how to set the indentation of the braces to line up as I want.

- New Lines: Array Initializer: Insert new line after opening brace of array initializer (checked)

- New Lines: Array Initializer: Insert new line before closing brace of array initializer (checked)

- Braces: Array Initializer: Next Line

- Line Wrapping: Array Initializers: Wrap all elements, each element on a new line, Indent by one

[Updated on: Wed, 08 October 2014 09:41] by Moderator

Re: Array braces formatting [message #1440607 is a reply to message #1439850] Wed, 08 October 2014 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Okay, I found the answer. Under Indentation, don't select "Align fields in columns".

Of course, when you de-select it, you also get

    int theInt = 1;
    String someString = "Hello";
    double aDouble = 3.0;

instead of

    int    theInt     = 1;
    String someString = "Hello";
    double aDouble    = 3.0;

So, why don't the selected rules for braces apply to braces used in array declarations?

And why can't I line up the '='s in a set of assignments as the above option does for '='s in declarations?

I suspect the answers are the same: "The tool doesn't work that way".
Re: Array braces formatting [message #1440660 is a reply to message #1440607] Wed, 08 October 2014 13:12 Go to previous message
Eclipse UserFriend
Automatic code formatting is a moving target; you're never going to be able to match every person's exact desires for every situation. Even trying to do so results in a formatter framework with so many configuration options that it becomes nearly unusable.
Having said that, you're welcome to submit enhancement requests into Bugzilla; just be aware that the backlog of requests and bug reports is enormous, so unless you dive in an offer to help with implementation don't expect it to be implemented soon.

[Updated on: Wed, 08 October 2014 13:13] by Moderator

Previous Topic:Bookmarks
Next Topic:Broken plugin troubles
Goto Forum:
  


Current Time: Sat Jul 05 07:29:13 EDT 2025

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

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

Back to the top