CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); ImportEdit edit= new ImportEdit(cu, settings); edit.addImport(castDestType); proposal.getCompilationUnitChange().addTextEdit("import", edit);
addImportToProposal(cu, castDestType, proposal);
	public static void addCastProposals(ProblemPosition problemPos, ArrayList proposals) throws CoreException {		String[] args= problemPos.getArguments();		if (args.length != 2) {			return;		}					ICompilationUnit cu= problemPos.getCompilationUnit();		String castDestType= args[1];		CompilationUnit astRoot= AST.parseCompilationUnit(cu, false);		ASTNode selectedNode= ASTResolving.findSelectedNode(astRoot, problemPos.getOffset(), problemPos.getLength());				int pos= problemPos.getOffset();		if (selectedNode != null && selectedNode.getParent() != null) {			int parentNodeType= selectedNode.getParent().getNodeType();			if (parentNodeType == ASTNode.ASSIGNMENT) {				Assignment assign= (Assignment) selectedNode.getParent();				if (selectedNode.equals(assign.getLeftHandSide())) {					pos= assign.getRightHandSide().getStartPosition();				}			} else if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {				VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent();				if (selectedNode.equals(frag.getName())) {					pos= frag.getInitializer().getStartPosition();				}			}		}		String simpleCastDestType= Signature.getSimpleName(castDestType);				String cast= '(' + simpleCastDestType + ')';		String formatted= StubUtility.codeFormat(cast + 'x', 0, "");  //$NON-NLS-1$		if (formatted.charAt(formatted.length() - 1) == 'x') {			cast= formatted.substring(0, formatted.length() - 1);		}							String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.addcast.description", castDestType); //$NON-NLS-1$		InsertCorrectionProposal proposal= new InsertCorrectionProposal(label, cu, pos, cast, 1);				CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();		ImportEdit edit= new ImportEdit(cu, settings);		edit.addImport(castDestType);		proposal.getCompilationUnitChange().addTextEdit("import", edit); //$NON-NLS-1$				proposals.add(proposal);				if (selectedNode != null && selectedNode.getParent() instanceof VariableDeclarationFragment) {			VariableDeclarationFragment fragment= (VariableDeclarationFragment) selectedNode.getParent();			ASTNode parent= fragment.getParent();			Type type= null;			if (parent instanceof VariableDeclarationStatement) {				VariableDeclarationStatement stmt= (VariableDeclarationStatement) parent;				if (stmt.fragments().size() == 1) {					type= stmt.getType();				}			} else if (parent instanceof FieldDeclaration) {				FieldDeclaration decl= (FieldDeclaration) parent;				if (decl.fragments().size() == 1) {					type= decl.getType();				}			}						if (type != null) {				String castType= args[0];				String simpleCastType= Signature.getSimpleName(castType);				label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.addcast_var.description", simpleCastType); //$NON-NLS-1$				ReplaceCorrectionProposal varProposal= new ReplaceCorrectionProposal(label, cu, type.getStartPosition(), type.getLength(), simpleCastType, 1);				edit= new ImportEdit(cu, settings);				edit.addImport(castType);				varProposal.getCompilationUnitChange().addTextEdit("import", edit); //$NON-NLS-1$								proposals.add(varProposal);			}		}				}