final IType newEnumType = page.getCreatedType();
final CompilationUnit node = (CompilationUnit) Util.getASTNode(
newEnumType, monitor);
final ASTRewrite astRewrite = ASTRewrite.create(node.getAST());
final ImportRewrite importRewrite = ImportRewrite
.create(node, true);
final EnumDeclaration oldEnumDeclaration = (EnumDeclaration) node
.types().get(0);
// Add imports for annotations to the enum constants.
for (final Iterator eit = newEnumDeclaration.enumConstants()
.iterator(); eit.hasNext();) {
final Object obj = eit.next();
final EnumConstantDeclaration ecd = (EnumConstantDeclaration) obj;
for (final Iterator emit = ecd.modifiers().iterator(); emit
.hasNext();) {
final Object o = emit.next();
if (o instanceof Annotation) {
final Annotation anno = (Annotation) o;
final String newName = importRewrite
.addImport((String) annotationToQualifiedNameMap
.get(anno));
anno.setTypeName(ast.newName(newName));
}
}