CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); ImportEdit edit= new ImportEdit(problemPos.getCompilationUnit(), settings); edit.addImport(type.getName()); proposal.getCompilationUnitChange().addTextEdit("import", edit);
addImportToProposal(problemPos.getCompilationUnit(), type, proposal);
	public static void addMissingReturnTypeProposals(ProblemPosition problemPos, ArrayList proposals) throws CoreException {		ICompilationUnit cu= problemPos.getCompilationUnit();				CompilationUnit astRoot= AST.parseCompilationUnit(cu, true);		ASTNode selectedNode= ASTResolving.findSelectedNode(astRoot, problemPos.getOffset(), problemPos.getLength());		if (selectedNode != null) {			BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode);			if (decl instanceof MethodDeclaration) {				final ITypeBinding[] res= new ITypeBinding[1];				res[0]= null;								decl.accept(new GenericVisitor() {					public boolean visit(ReturnStatement node) {						if (res[0] == null) {							Expression expr= node.getExpression();							if (expr != null) {								ITypeBinding binding= expr.resolveTypeBinding();								if (binding != null) {									res[0]= binding;								} else {									res[0]= node.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$								}							} else {								res[0]= node.getAST().resolveWellKnownType("void"); //$NON-NLS-1$							}						}						return false;					}				});				ITypeBinding type= res[0];				if (type == null) {					type= decl.getAST().resolveWellKnownType("void"); //$NON-NLS-1$				} 								String str= type.getName() + " "; //$NON-NLS-1$				int pos= ((MethodDeclaration) decl).getName().getStartPosition();								String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.missingreturntype.description", type.getName()); //$NON-NLS-1$				InsertCorrectionProposal proposal= new InsertCorrectionProposal(label, cu, pos, str, 1);							CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();				ImportEdit edit= new ImportEdit(problemPos.getCompilationUnit(), settings);				edit.addImport(type.getName());				proposal.getCompilationUnitChange().addTextEdit("import", edit); //$NON-NLS-1$						proposals.add(proposal);			}		}	}