public static void addMethodRetunsVoidProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof ReturnStatement)) { return; } ReturnStatement returnStatement= (ReturnStatement) selectedNode; Expression expression= returnStatement.getExpression(); if (expression == null) { return; } BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methDecl= (MethodDeclaration) decl; Type retType= methDecl.getReturnType2(); if (retType == null || retType.resolveBinding() == null) { return; } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, 4, proposals); } } }
if (!isDeclaredException(methodExceptions[i], definedExceptions)) { changes[i]= new RemoveDescription(); undeclaredExceptions.add(methodExceptions[i]);
castFixType= castType; } else if (JavaModelUtil.is50OrHigher(cu.getJavaProject())) { ITypeBinding boxUnboxedTypeBinding= TypeMismatchSubProcessor.boxUnboxPrimitives(castType, binding, nodeToCast.getAST()); if (boxUnboxedTypeBinding != castType && boxUnboxedTypeBinding.isCastCompatible(binding)) { castFixType= boxUnboxedTypeBinding; ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castFixType, nodeToCast, IProposalRelevance.CAST_ARGUMENT_1); String castTypeName= BindingLabelProvider.getBindingLabel(castFixType, JavaElementLabels.ALL_DEFAULT); String[] arg= new String[] { getArgumentName(arguments, idx), castTypeName}; TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, IProposalRelevance.CAST_ARGUMENT_2, proposals);
case IProblem.TypeMismatch: case IProblem.ReturnTypeMismatch: TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals); break; case IProblem.IncompatibleTypesInForeach: TypeMismatchSubProcessor.addTypeMismatchInForEachProposals(context, problem, proposals); break; case IProblem.IncompatibleReturnType: TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals); break; case IProblem.IncompatibleExceptionInThrowsClause: TypeMismatchSubProcessor.addIncompatibleThrowsProposals(context, problem, proposals); break; case IProblem.UnhandledException:
break; case IProblem.TypeMismatch: TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals); break; case IProblem.IncompatibleReturnType: TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals); break; case IProblem.IncompatibleExceptionInThrowsClause: TypeMismatchSubProcessor.addIncompatibleThrowsProposals(context, problem, proposals); break; case IProblem.UnhandledException:
ITypeBinding binding= nodeToCast.resolveTypeBinding(); if (binding == null || binding.isCastCompatible(castType)) { ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castType, nodeToCast, 6); String castTypeName= BindingLabelProvider.getBindingLabel(castType, JavaElementLabels.ALL_DEFAULT); String[] arg= new String[] { getArgumentName(cu, arguments, idx), castTypeName}; proposals.add(proposal); TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, 5, proposals);
castFixType= castType; } else if (JavaModelUtil.is50OrHigher(cu.getJavaProject())) { ITypeBinding boxUnboxedTypeBinding= TypeMismatchSubProcessor.boxUnboxPrimitives(castType, binding, nodeToCast.getAST()); if (boxUnboxedTypeBinding != castType && boxUnboxedTypeBinding.isCastCompatible(binding)) { castFixType= boxUnboxedTypeBinding; ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castFixType, nodeToCast, IProposalRelevance.CAST_ARGUMENT_1); String castTypeName= BindingLabelProvider.getBindingLabel(castFixType, JavaElementLabels.ALL_DEFAULT); String[] arg= new String[] { getArgumentName(arguments, idx), castTypeName}; TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, IProposalRelevance.CAST_ARGUMENT_2, proposals);
case IProblem.TypeMismatch: case IProblem.ReturnTypeMismatch: TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals); break; case IProblem.IncompatibleTypesInForeach: TypeMismatchSubProcessor.addTypeMismatchInForEachProposals(context, problem, proposals); break; case IProblem.IncompatibleReturnType: TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals); break; case IProblem.IncompatibleExceptionInThrowsClause: TypeMismatchSubProcessor.addIncompatibleThrowsProposals(context, problem, proposals); break; case IProblem.UnhandledException:
break; case IProblem.TypeMismatch: TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals); break; case IProblem.IncompatibleReturnType: TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals); break; case IProblem.IncompatibleExceptionInThrowsClause: TypeMismatchSubProcessor.addIncompatibleThrowsProposals(context, problem, proposals); break; case IProblem.UnhandledException:
ITypeBinding binding= nodeToCast.resolveTypeBinding(); if (binding == null || binding.isCastCompatible(castType)) { ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castType, nodeToCast, 6); String castTypeName= BindingLabelProvider.getBindingLabel(castType, JavaElementLabels.ALL_DEFAULT); String[] arg= new String[] { getArgumentName(cu, arguments, idx), castTypeName}; proposals.add(proposal); TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, 5, proposals);
castFixType= castTypeBinding; } else if (JavaModelUtil.is50OrHigher(cu.getJavaProject())) { ITypeBinding boxUnboxedTypeBinding= boxUnboxPrimitives(castTypeBinding, currBinding, ast); if (boxUnboxedTypeBinding != castTypeBinding && boxUnboxedTypeBinding.isCastCompatible(currBinding)) { castFixType= boxUnboxedTypeBinding; proposals.add(createCastProposal(context, castFixType, nodeToCast, IProposalRelevance.CREATE_CAST)); currBinding= ASTResolving.normalizeWildcardType(currBinding, true, ast); addChangeSenderTypeProposals(context, receiverNode, currBinding, true, IProposalRelevance.CHANGE_TYPE_OF_RECEIVER_NODE, proposals); addChangeSenderTypeProposals(context, nodeToCast, castTypeBinding, false, IProposalRelevance.CHANGE_TYPE_OF_NODE_TO_CAST, proposals);
ITypeBinding binding= nodeToCast.resolveTypeBinding(); if (binding == null || binding.isCastCompatible(castTypeBinding) || nodeToCast instanceof CastExpression) { proposals.add(createCastProposal(context, castTypeBinding, nodeToCast, 7)); currBinding= ASTResolving.normalizeWildcardType(currBinding, true, ast); addChangeSenderTypeProposals(context, receiverNode, currBinding, true, 6, proposals); addChangeSenderTypeProposals(context, nodeToCast, castTypeBinding, false, 5, proposals);
public static void addMethodRetunsVoidProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof ReturnStatement)) { return; } ReturnStatement returnStatement= (ReturnStatement) selectedNode; Expression expression= returnStatement.getExpression(); if (expression == null) { return; } BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methDecl= (MethodDeclaration) decl; Type retType= methDecl.getReturnType2(); if (retType == null || retType.resolveBinding() == null) { return; } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, IProposalRelevance.METHOD_RETURNS_VOID, proposals); } } }
if (!isDeclaredException(methodExceptions[i], definedExceptions)) { changes[i]= new RemoveDescription(); undeclaredExceptions.add(methodExceptions[i]);
castFixType= castTypeBinding; } else if (JavaModelUtil.is50OrHigher(cu.getJavaProject())) { ITypeBinding boxUnboxedTypeBinding= boxUnboxPrimitives(castTypeBinding, currBinding, ast); if (boxUnboxedTypeBinding != castTypeBinding && boxUnboxedTypeBinding.isCastCompatible(currBinding)) { castFixType= boxUnboxedTypeBinding; proposals.add(createCastProposal(context, castFixType, nodeToCast, IProposalRelevance.CREATE_CAST)); currBinding= ASTResolving.normalizeWildcardType(currBinding, true, ast); addChangeSenderTypeProposals(context, receiverNode, currBinding, true, IProposalRelevance.CHANGE_TYPE_OF_RECEIVER_NODE, proposals); addChangeSenderTypeProposals(context, nodeToCast, castTypeBinding, false, IProposalRelevance.CHANGE_TYPE_OF_NODE_TO_CAST, proposals);
public static void addMethodRetunsVoidProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof ReturnStatement)) { return; } ReturnStatement returnStatement= (ReturnStatement) selectedNode; Expression expression= returnStatement.getExpression(); if (expression == null) { return; } BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methDecl= (MethodDeclaration) decl; Type retType= methDecl.getReturnType2(); if (retType == null || retType.resolveBinding() == null) { return; } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, IProposalRelevance.METHOD_RETURNS_VOID, proposals); } } }
if (!isDeclaredException(methodExceptions[i], definedExceptions)) { changes[i]= new RemoveDescription(); undeclaredExceptions.add(methodExceptions[i]);