Bug 45426

Summary: wrong indentation on anonymous inner class method
Product: [Eclipse Project] JDT Reporter: Eric Seynaeve <eseynaeve>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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.