Bug 79752 - Need access to type binding of anonymous enumerations
Summary: Need access to type binding of anonymous enumerations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 03:55 EST by Dirk Baeumer CLA
Modified: 2004-12-15 13:24 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2004-11-30 03:55:38 EST
enum XXX {
  A { void foo() {}};
}

- currently there is now API to access the typ[e binding of the anonymous enum
  created by { void foo() {}}

To make anonymous enums more consistent with AnonymousClassDeclaration the
EnumConstantDeclaration should have a subnode AnonymousEnumDeclaration. 
The AnonymousEnumDeclaration would then resolve to a ITypeBinding.

As with type declarations there should be an abstract class
AbstractAnonymousTypeDeclaration which works as a super class for
AnonymousEnumDeclaration and AnonymousTypeDeclaration.
Comment 1 Jim des Rivieres CLA 2004-11-30 10:05:06 EST
I agree. EnumConstantDeclaration should have the same form as 
ClassInstanceCreation nodes, which factors off the class body declarations 
into an AnonymousClassDeclaration. However, I don't see any real need to 
introduce a new AnonymousEnumDeclaration node type; the existing 
AnonymousClassDeclaration is sufficient.
Comment 2 Dirk Baeumer CLA 2004-11-30 10:32:15 EST
Only having the AnonymousClassDeclaration is fine with me. I proposed the split
since enums aren't classes <g>.
Comment 3 Jim des Rivieres CLA 2004-11-30 11:49:19 EST
I've changed the API to add a new anonymousClassDeclaration property to 
EnumConstantDeclaration nodes. The old bodyDeclarations property has been 
deprecated, and will be deleted after 3.1 M4 (it is JLS3-specific API).

(Note: Change affects NaiveASTFlattener as well.)

Olivier, please fix up the AST converter.
Martin, please fix up the AST rewriter.
Comment 4 Martin Aeschlimann CLA 2004-11-30 12:59:51 EST
fixed AST rewriter. Test currently disabled, until AST converter is updated
(ASTRewritingMethodDeclTest.testEnumConstantDeclaration2()).
Comment 5 Olivier Thomann CLA 2004-11-30 15:02:59 EST
Fixed and released in HEAD.
Regression test added. Updated test0026 in ASTConverter15Test.
Comment 6 Olivier Thomann CLA 2004-11-30 15:10:29 EST
Reopen to assign to Martin.
Comment 7 Olivier Thomann CLA 2004-11-30 15:11:49 EST
Martin,

I enable your test case, but I had to add an extra empty line between two
methods in the anonymous declaration for constant E5Add. Please check the test
case and update it according to what you expect.
Comment 8 Martin Aeschlimann CLA 2004-11-30 17:54:44 EST
Thanks! The fix is correct, the empty line is what is to be expected.
Back to Olivier to mark as fixed
Comment 9 Olivier Thomann CLA 2004-11-30 17:56:23 EST
Fixed and released in HEAD.
Comment 10 Frederic Fusier CLA 2004-12-15 13:24:53 EST
Verified for 3.1 M4 using build I200412142000 + ASTView 1.0.2.