ITypeBinding guessedCastTypeBinding= ASTResolving.guessBindingForReference(nodeToCast); castTypeBinding= guessedCastTypeBinding;
castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
	public static void addTypeMismatchProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {		String[] args= problem.getProblemArguments();		if (args.length != 2) {			return;		}		ICompilationUnit cu= context.getCompilationUnit();		CompilationUnit astRoot= context.getASTRoot();		AST ast= astRoot.getAST();				ASTNode selectedNode= problem.getCoveredNode(astRoot);		if (!(selectedNode instanceof Expression)) {			return;		}		Expression nodeToCast= (Expression) selectedNode;		Name receiverNode= null;		ITypeBinding castTypeBinding= null;		int parentNodeType= selectedNode.getParent().getNodeType();		if (parentNodeType == ASTNode.ASSIGNMENT) {			Assignment assign= (Assignment) selectedNode.getParent();			Expression leftHandSide= assign.getLeftHandSide();			if (selectedNode.equals(leftHandSide)) {				nodeToCast= assign.getRightHandSide();			}			castTypeBinding= assign.getLeftHandSide().resolveTypeBinding();			if (leftHandSide instanceof Name) {				receiverNode= (Name) leftHandSide;			} else if (leftHandSide instanceof FieldAccess) {				receiverNode= ((FieldAccess) leftHandSide).getName();			}		} else if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {			VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent();			if (selectedNode.equals(frag.getName()) || selectedNode.equals(frag.getInitializer())) {				nodeToCast= frag.getInitializer();				castTypeBinding= ASTNodes.getType(frag).resolveBinding();				receiverNode= frag.getName();			}		} else {			// try to find the binding corresponding to 'castTypeName'			ITypeBinding guessedCastTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);			castTypeBinding= guessedCastTypeBinding;		}		if (castTypeBinding == null) {			return;		}		ITypeBinding binding= nodeToCast.resolveTypeBinding();		if (binding == null || binding.isCastCompatible(castTypeBinding) || nodeToCast instanceof CastExpression) {			proposals.add(createCastProposal(context, castTypeBinding, nodeToCast, 7));		}		ITypeBinding currBinding= nodeToCast.resolveTypeBinding();		boolean nullOrVoid= currBinding == null || "void".equals(currBinding.getName()); //$NON-NLS-1$		// change method return statement to actual type		if (!nullOrVoid && parentNodeType == ASTNode.RETURN_STATEMENT) {			BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode);			if (decl instanceof MethodDeclaration) {				MethodDeclaration methodDeclaration= (MethodDeclaration) decl;				currBinding= Bindings.normalizeTypeBinding(currBinding);				if (currBinding == null) {					currBinding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$				}				if (currBinding.isWildcardType()) {					currBinding= ASTResolving.normalizeWildcardType(currBinding, true, ast);				}				ASTRewrite rewrite= ASTRewrite.create(ast);				NewImportRewrite imports= NewImportRewrite.create(astRoot, true);				Type newReturnType= imports.addImport(currBinding, ast);				rewrite.replace(methodDeclaration.getReturnType2(), newReturnType, null);				String label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturntype_description, currBinding.getName());				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);				LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, 6, image);				proposal.setImportRewrite(imports);				String returnKey= "return"; //$NON-NLS-1$				proposal.addLinkedPosition(rewrite.track(newReturnType), true, returnKey);				ITypeBinding[] typeSuggestions= ASTResolving.getRelaxingTypes(ast, currBinding);				for (int i= 0; i < typeSuggestions.length; i++) {					proposal.addLinkedPositionProposal(returnKey, typeSuggestions[i]);				}				proposals.add(proposal);			}		}		if (!nullOrVoid && receiverNode != null) {			currBinding= Bindings.normalizeTypeBinding(currBinding);			if (currBinding == null) {				currBinding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$			}			if (currBinding.isWildcardType()) {				currBinding= ASTResolving.normalizeWildcardType(currBinding, true, ast);			}			addChangeSenderTypeProposals(context, receiverNode, currBinding, true, 6, proposals);		}		if (castTypeBinding != null) {			addChangeSenderTypeProposals(context, nodeToCast, castTypeBinding, false, 5, proposals);		}	}