public static boolean isUseableTypeInContext(ITypeBinding[] binding, IBinding context, boolean noWildcards) { for (int i= 0; i < binding.length; i++) { if (!isUseableTypeInContext(binding[i], context, noWildcards)) { return false; } } return true; }
public boolean visit(ITypeBinding node) { node= Bindings.normalizeTypeBinding(node); if (node == null) { return true; } if (!fVisitedBindings.add(node.getKey())) { return true; } if (node.isGenericType()) { return true; // only look at parameterized types } if (context != null && !isUseableTypeInContext(node, context, false)) { return true; } IMethodBinding[] methods= node.getDeclaredMethods(); for (int i= 0; i < methods.length; i++) { IMethodBinding meth= methods[i]; if (meth.getName().equals(selector) && meth.getParameterTypes().length == nArgs) { result.add(node); } } return true; } });
@Override public boolean visit(ITypeBinding node) { node= Bindings.normalizeTypeBinding(node); if (node == null) { return true; } if (!fVisitedBindings.add(node.getKey())) { return true; } if (node.isGenericType()) { return true; // only look at parameterized types } if (context != null && !isUseableTypeInContext(node, context, false)) { return true; } IMethodBinding[] methods= node.getDeclaredMethods(); for (int i= 0; i < methods.length; i++) { IMethodBinding meth= methods[i]; if (meth.getName().equals(selector) && meth.getParameterTypes().length == nArgs) { result.add(node); } } return true; } });
ITypeBinding[] typeParameters= type.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { if (!isUseableTypeInContext(typeParameters[i], context, noWildcards)) { return false; ITypeBinding[] typeArguments= type.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) { if (!isUseableTypeInContext(typeArguments[i], context, noWildcards)) { return false; return isUseableTypeInContext(type.getBound(), context, noWildcards);
ITypeBinding[] typeParameters= type.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { if (!isUseableTypeInContext(typeParameters[i], context, noWildcards)) { return false; ITypeBinding[] typeArguments= type.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) { if (!isUseableTypeInContext(typeArguments[i], context, noWildcards)) { return false; return isUseableTypeInContext(type.getBound(), context, noWildcards);
String sig= ASTResolving.getMethodSignature(methodName, parameterTypes, false); if (ASTResolving.isUseableTypeInContext(parameterTypes, senderDeclBinding, false)) { if (nodeParentType == senderDeclBinding) { label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_description, sig); if (anonymDecl != null) { senderDeclBinding= Bindings.getBindingOfParentType(anonymDecl.getParent()); if (!senderDeclBinding.isAnonymous() && ASTResolving.isUseableTypeInContext(parameterTypes, senderDeclBinding, false)) { String[] args= new String[] { sig, ASTResolving.getTypeSignature(senderDeclBinding) }; label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_other_description, args);
String sig= ASTResolving.getMethodSignature(methodName, parameterTypes, false); if (ASTResolving.isUseableTypeInContext(parameterTypes, senderDeclBinding, false)) { if (nodeParentType == senderDeclBinding) { label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_description, sig); if (anonymDecl != null) { senderDeclBinding= Bindings.getBindingOfParentType(anonymDecl.getParent()); if (!senderDeclBinding.isAnonymous() && ASTResolving.isUseableTypeInContext(parameterTypes, senderDeclBinding, false)) { String[] args= new String[] { sig, ASTResolving.getTypeSignature(senderDeclBinding) }; label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_other_description, args);
targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCu != null && ASTResolving.isUseableTypeInContext(castTypeBinding, callerBindingDecl, false)) { proposals.add(new TypeChangeCorrectionProposal(targetCu, callerBindingDecl, astRoot, castTypeBinding, isAssignedNode, relevance)); ITypeBinding typeDecl= nodeType.getTypeDeclaration(); ICompilationUnit nodeCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, typeDecl); if (nodeCu != null && ASTResolving.isUseableTypeInContext(castTypeBinding, typeDecl, true)) { proposals.add(new ImplementInterfaceProposal(nodeCu, typeDecl, astRoot, castTypeBinding, relevance - 1));
targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCu != null && ASTResolving.isUseableTypeInContext(castTypeBinding, callerBindingDecl, false)) { proposals.add(new TypeChangeCompletionProposal(targetCu, callerBindingDecl, astRoot, castTypeBinding, isAssignedNode, relevance)); ITypeBinding typeDecl= nodeType.getTypeDeclaration(); ICompilationUnit nodeCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, typeDecl); if (nodeCu != null && ASTResolving.isUseableTypeInContext(castTypeBinding, typeDecl, true)) { proposals.add(new ImplementInterfaceProposal(nodeCu, typeDecl, astRoot, castTypeBinding, relevance - 1));
targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, overridenDeclType); if (targetCu != null && ASTResolving.isUseableTypeInContext(returnType, overriddenDecl, false)) { TypeChangeCompletionProposal proposal= new TypeChangeCompletionProposal(targetCu, overriddenDecl, astRoot, returnType, false, 7); if (overridenDeclType.isInterface()) {
newType= ASTResolving.normalizeWildcardType(newType, true, astRoot.getAST()); if (!ASTResolving.isUseableTypeInContext(newType, methodDecl, false)) { return;
newType= ASTResolving.normalizeWildcardType(newType, true, astRoot.getAST()); if (!ASTResolving.isUseableTypeInContext(newType, methodDecl, false)) { return;
if (targetCu != null && ASTResolving.isUseableTypeInContext(returnType, overriddenDecl, false)) { TypeChangeCorrectionProposal proposal= new TypeChangeCorrectionProposal(targetCu, overriddenDecl, astRoot, returnType, false, IProposalRelevance.CHANGE_RETURN_TYPE_OF_OVERRIDDEN); if (overridenDeclType.isInterface()) {
newType= ASTResolving.normalizeWildcardType(newType, true, astRoot.getAST()); if (!ASTResolving.isUseableTypeInContext(newType, methodDecl, false)) { return;