Community
Participate
Working Groups
I20050209 (jdt-core of 20050215) EnumConstantDeclaration should allow me to query its method binding, as declaring an enum constant also invokes a constructor: enum Natural { ONE(1), TWO(2); private final int fInt; Natural(int n) { fInt= n; } } I would expect a method similar to ClassInstanceCreation: public IMethodBinding resolveConstructorBinding();
I am not sure I want to see the enum constants highlighted like a method invocation. From my point of view, this is more a field constant.
EnumConstantDeclarations have a double nature of both constructor invocations and constant declarations (plus anonymous class decls sometimes). How this is presented in the UI is a different story, but the AST element should provide all that information. Note that we *do* render EnumConstants like constant fields currently.
(In reply to comment #2) > Note that we *do* render EnumConstants like constant fields currently. ...and we don't plan to change this. The dependent bug is about the autoboxing highlighting, where we analyze the type bindings of, amongst other things, method parameters. We also want to highlight the autoboxed parameters inside the enum constant declarations: static final int one= 1, two= 2; static enum Natural { ONE(one), TWO(two); private final Integer n; Natural(Integer n) { this.n= n; } }
Enum constants are definitely some sort of field constants. Now in compiler land, they are provided with an initialization expression which is an allocation (normal or qualified when constant body is supplied). Why not simply doing the same ?
Autoboxing diagnosis can be implemented using the forthcoming API: isBoxed()/isUnboxed()
Adding public IMethodBinding resolveConstructorBinding(); to EnumConstantDeclaration makes sense as a way of exposing the constructor invoked in the enum constant declaration.
API has been added. Regression tests added in ASTConverter15Test. I updated existing tests. Look for references to resolveConstructorBinding().
Fixed and released.
Verified in 20050330-0500