if (type != null){
CompilationUnit astRoot = SharedASTProvider
.getAST(src, SharedASTProvider.WAIT_YES, null);
edits = new MultiTextEdit();
ImportRewrite importRewrite = StubUtility.createImportRewrite(astRoot, true);
ImportRewriteContext context = new ContextSensitiveImportRewriteContext(
astRoot, offset, importRewrite);
String res = importRewrite.addImport(type, context);
if (type.equals(res)){
return CodeGenerationMessages.AddImportsOperation_error_importclash;
}
TextEdit rewrite = importRewrite.rewriteImports(null);
edits.addChild(rewrite);
JavaModelUtil.applyEdit(src, edits, true, null);
}else{
ChooseImport query = new ChooseImport(project, type);