Bug 45426 - wrong indentation on anonymous inner class method
Summary: wrong indentation on anonymous inner class method
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-23 04:36 EDT by Eric Seynaeve CLA
Modified: 2003-10-23 08:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seynaeve CLA 2003-10-23 04:36:28 EDT
After applying code formatting, the code is reformatted to the following:

public class ...
  public void ...() {
    ...
    TestUtils
      .testName(
        ACCEPTABLE_NAMES,
        UNACCEPTABLE_NAMES,
        new TestUtils.TestNamesWithCommonObject(c) {
      public void doTest(String name) throws Exception {
        ((Company) getObject()).setName(name);
      }
    }, MalformedNameException.class);
  }
}

Besides the extreme usage of vertical screen space, the indentation of the
method of the anonymous inner class is a whee bit to the left. Also, the closing
curly bracket of the anonymous inner class definition is to very leftish. As
humble suggestion for good formatting:

public class ...
  public void ...() {
    ...
    TestUtils.testName(
      ACCEPTABLE_NAMES, 
      UNACCEPTABLE_NAMES,
      new TestUtils.TestNamesWithCommonObject(c) {
        public void doTest(String name) throws Exception {
          ((Company) getObject()).setName(name);
        }
      }, MalformedNameException.class
    );
  }
}

Eclipse version 3.0M4 on Win 2000
Build id: 200310101454
Comment 1 Eric Seynaeve CLA 2003-10-23 08:00:49 EDT
Ahum, I had the new code formatter disabled. My bad. After enabling it and
reformatting the code, the result is the following:

public void testCompanyConstructor() {
  TestUtils.testName(ACCEPTABLE_NAMES, UNACCEPTABLE_NAMES,
      new TestUtils.TestNameInterface() {
        public void doTest(String name) throws Exception {
          Company c = new Company(name);
        }
      }, MalformedNameException.class);
}

Now I can only nitpick that the larger 'gap' looks a bit weird. I guess that is
more a matter of taste ;-)
Comment 2 Olivier Thomann CLA 2003-10-23 08:03:40 EDT
I was about to ask you if you enabled the new formatter. Ok to close?
Comment 3 Eric Seynaeve CLA 2003-10-23 08:13:05 EDT
Go ahead and close. It looks solved for me.

Thanks and keep up the good work ;-)
Comment 4 Olivier Thomann CLA 2003-10-23 08:18:12 EDT
Close as WORKSFORME.