示例#1
0
 private IVariableBinding[] getEnumContants(ITypeBinding binding) {
   IVariableBinding[] declaredFields = binding.getDeclaredFields();
   ArrayList<IVariableBinding> res = new ArrayList<IVariableBinding>(declaredFields.length);
   for (int i = 0; i < declaredFields.length; i++) {
     IVariableBinding curr = declaredFields[i];
     if (curr.isEnumConstant()) {
       res.add(curr);
     }
   }
   return res.toArray(new IVariableBinding[res.size()]);
 }
示例#2
0
 @Override
 public boolean visit(SwitchCase node) {
   // switch on enum allows to use enum constants without qualification
   if (hasFlag(VARIABLES, fFlags) && !node.isDefault() && isInside(node.getExpression())) {
     SwitchStatement switchStatement = (SwitchStatement) node.getParent();
     ITypeBinding binding = switchStatement.getExpression().resolveTypeBinding();
     if (binding != null && binding.isEnum()) {
       IVariableBinding[] declaredFields = binding.getDeclaredFields();
       for (int i = 0; i < declaredFields.length; i++) {
         IVariableBinding curr = declaredFields[i];
         if (curr.isEnumConstant()) {
           fBreak = fRequestor.acceptBinding(curr);
           if (fBreak) return false;
         }
       }
     }
   }
   return false;
 }