Community
Participate
Working Groups
20050105 public enum E { A, B, C; public static final int X= 9; } Get the IVariableBindings for E. I would like to know which of the variables are enum constant declarations and which not. Possibilities to fix this would be new API 'Modifier.isEnum(modifiers)' or something like 'IVariableBinding.isEnumConstant()'
Jim, any comment?
The case is even more interesting when the enum has self-typed fields; i.e., public enum E { A, B, C; public static E D; } Checking whether the variable's type is the same enum type as the variable's declaring class would not cut it. Adding IVariableBinding.isEnumConstant() feels like a good approach.
Adding API IVariableBinding.isEnumConstant(). I also clarified the spec for IVariableBinding.getConstantValue() to specify that it returns null for enum constants. This approach is consistent with JLS3 15.28, which does not consider enumeration types to be compile-time constant expressions. Olivier, please complete VariableBinding.isEnumConstant() implementation and add tests.
The test needs to be done on the modifiers of the binding. An enum constant has AccEnum is its bits. Fixed and released in HEAD. Regression test added in ASTConverter15Test.test0100.
Verified in I20050215-2300