Summary: | [1.5] programmatically created Enum gets bad formatting | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Danny Dig <dannydig> |
Component: | Core | Assignee: | Martin Aeschlimann <martinae> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | dirk_baeumer, jeem |
Version: | 3.0 | ||
Target Milestone: | 3.1 M2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Danny Dig
2004-07-28 06:07:37 EDT
Instead of TypeDeclaration.BODY_DECLARATIONS_PROPERTY, should not you have EnumDeclaration.BODY_DECLARATIONS_PROPERTY? I also don't understand why the enumConstants are part of the body declarations. I don't see how it is possible to get the semicolon between the constants and the body declarations. Jim, any idea? Olivier, The enum constant declarations are the first elements of EnumDeclaration.bodyDeclarations. See NaiveASTFlattener.visit(EnumDeclaration) for an example of how to put the comma separators between enum constants and the semicolon separating the enum constants from the rest of the body decls. Olivier, replacing TypeDeclaration.BODY_DECLARATION_PROPERTY with EnumDeclaration.BODY_DECLARATION_PROPERTY results in the following exception (below is the stack trace): java.lang.IllegalArgumentException: TypeDeclaration has no property bodyDeclarations at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.validateHasChildPro perty(RewriteEventStore.java:615) at org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.getEvent (RewriteEventStore.java:296) at org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.getListEvent (RewriteEventStore.java:325) at org.eclipse.jdt.core.dom.rewrite.ListRewrite.getEvent (ListRewrite.java:56) at org.eclipse.jdt.core.dom.rewrite.ListRewrite.internalInsertAt (ListRewrite.java:261) at org.eclipse.jdt.core.dom.rewrite.ListRewrite.insertFirst (ListRewrite.java:206) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractEnumRefactoring.cr eateEnumDeclaration(ExtractEnumRefactoring.java:379) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractEnumRefactoring.cr eateChange(ExtractEnumRefactoring.java:329) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:117) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:188) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1673) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1693) at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.performRefactoring (RefactoringTest.java:177) at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.performRefactoring (RefactoringTest.java:166) at org.eclipse.jdt.ui.tests.refactoring.ExtractEnumTest.canExtractEnum (ExtractEnumTest.java:66) at org.eclipse.jdt.ui.tests.refactoring.ExtractEnumTest.testSimpleSameCU (ExtractEnumTest.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:59) at java.lang.reflect.Method.invoke(Method.java:390) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:421) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:305) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main (RemotePluginTestRunner.java:30) at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run (UITestApplication.java:92) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:106) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2749) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2434) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1435) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1406) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:263) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:102)package p; This seems to be a bug in the rewriter that doesn't handle the enum constant declarations specifically. It seems to consider all declarations as body declarations. The bug was in the ast rewriter flattener code.
I detected the same bug in the NaiveASTFlattener: The iteration over the enum
bodyDeclarations did not update the 'prev' variable
Jeem, I added and released the missing statement as well in the NaiveASTFlattener
> 20040901
Verified in I200409240100. |