// Build the enum constants.
//
NodeList<EnumConstantDeclaration> constants = node.getConstants();
int constantCount = constants.size();
for (int i = 0; i < constantCount; i++) {
SimpleIdentifier constantName = constants.get(i).getName();
FieldElementImpl constantField = new ConstFieldElementImpl(constantName);
constantField.setStatic(true);
constantField.setConst(true);
constantField.setType(enumType);
//
// Create a value for the constant.
//
HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImpl>();
fieldMap.put(indexFieldName, new DartObjectImpl(intType, new IntState(BigInteger.valueOf(i))));
DartObjectImpl value = new DartObjectImpl(enumType, new GenericState(fieldMap));
constantField.setEvaluationResult(new ValidResult(value));
fields.add(constantField);
getters.add(createGetter(constantField));
constantName.setStaticElement(constantField);
}
//
// Finish building the enum.
//
enumElement.setFields(fields.toArray(new FieldElement[fields.size()]));