List imports = astRoot.imports();
List importsToBeRemoved = new ArrayList();
for (Iterator j = imports.iterator(); j.hasNext();) {
ImportDeclaration anImportDecl = (ImportDeclaration) j.next();
String importName = anImportDecl.getName().getFullyQualifiedName();
if (importName.endsWith("Exception") || //$NON-NLS-1$
importName.equals("com.google.gwt.core.client.GWT") || //$NON-NLS-1$
importName.equals("com.google.gwt.user.client.rpc.ServiceDefTarget") || //$NON-NLS-1$
importName.equals("com.google.gwt.user.client.rpc.RemoteService")//$NON-NLS-1$
)
importsToBeRemoved.add(anImportDecl);
}
imports.removeAll(importsToBeRemoved);
ImportDeclaration importDecl = ast.newImportDeclaration();
importDecl.setName(ast.newName("com.google.gwt.user.client.rpc.AsyncCallback")); //$NON-NLS-1$
astRoot.imports().add(importDecl);
// Add Async to the name
TypeDeclaration aRemoteService = (TypeDeclaration) astRoot.types().get(0);
String remoteServiceAsyncName = aRemoteService.getName().getFullyQualifiedName() + "Async"; //$NON-NLS-1$