private void coupleTo(ITypeBinding binding) { if (binding == null) return; if (binding.isWildcardType()) return; String type = binding.getQualifiedName(); if (type.equals("null")) return; if (!isFromJava(type) && !binding.isPrimitive()) coupling.add(type.replace("[]", "")); }
private static ITypeBinding[] getParameterTypes(List args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= (Expression) args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= (Expression) args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ChangeDescription[] createSignatureChangeDescription(int[] indexOfDiff, int nDiffs, ITypeBinding[] paramTypes, List<Expression> arguments, ITypeBinding[] argTypes) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; for (int i= 0; i < nDiffs; i++) { int diffIndex= indexOfDiff[i]; Expression arg= arguments.get(diffIndex); String name= getExpressionBaseName(arg); ITypeBinding argType= argTypes[diffIndex]; if (argType.isWildcardType()) { argType= ASTResolving.normalizeWildcardType(argType, true, arg.getAST()); if (argType== null) { return null; } } changeDesc[diffIndex]= new EditDescription(argType, name); } return changeDesc; }
protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
@Override protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
@Override protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
private String computeTypeProposal(ITypeBinding binding, ITypeParameter parameter) throws JavaModelException { final String name = TypeProposalUtils.getTypeQualifiedName(binding); if (binding.isWildcardType()) { if (binding.isUpperbound()) { // replace the wildcard ? with the type parameter name to get "E extends Bound" instead of "? extends Bound" // String contextName= name.replaceFirst("\\?", parameter.getElementName()); //$NON-NLS-1$ // upper bound - the upper bound is the bound itself return binding.getBound().getName(); } // no or upper bound - use the type parameter of the inserted type, as it may be more // restrictive (eg. List<?> list= new SerializableList<Serializable>()) return computeTypeProposal(parameter); } // not a wildcard but a type or type variable - this is unambigously the right thing to insert return name; }
public static ITypeBinding replaceWildcardsAndCaptures(ITypeBinding type) { while (type.isWildcardType() || type.isCapture() || (type.isArray() && type.getElementType().isCapture())) { ITypeBinding bound = type.getBound(); type = (bound != null) ? bound : type.getErasure(); } return type; }
private Type evaluateParameterType(AST ast, Expression elem, String key, ImportRewriteContext context) { ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding()); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, true, ast); } if (binding != null) { return getImportRewrite().addImport(binding, ast, context, TypeLocation.PARAMETER); } return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$ }
public static ICompilationUnit findCompilationUnitForBinding(ICompilationUnit cu, CompilationUnit astRoot, ITypeBinding binding) throws JavaModelException { if (binding == null || !binding.isFromSource() || binding.isTypeVariable() || binding.isWildcardType()) { return null; } ASTNode node= astRoot.findDeclaringNode(binding.getTypeDeclaration()); if (node == null) { ICompilationUnit targetCU= Bindings.findCompilationUnit(binding, cu.getJavaProject()); if (targetCU != null) { return targetCU; } return null; } else if (node instanceof AbstractTypeDeclaration || node instanceof AnonymousClassDeclaration) { return cu; } return null; }
private Type evaluateParameterType(AST ast, Expression elem, String key, ImportRewriteContext context) { ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding()); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, true, ast); } if (binding != null) { ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, binding); for (int i= 0; i < typeProposals.length; i++) { addLinkedPositionProposal(key, typeProposals[i]); } return getImportRewrite().addImport(binding, ast, context, TypeLocation.PARAMETER); } return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$ }
private Type evaluateParameterType(AST ast, Expression elem, String key, ImportRewriteContext context) { ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding()); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, true, ast); } if (binding != null) { ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, binding); for (int i= 0; i < typeProposals.length; i++) { addLinkedPositionProposal(key, typeProposals[i]); } return getImportRewrite().addImport(binding, ast, context); } return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$ }
private Type evaluateParameterType(AST ast, Expression elem, String key) throws CoreException { ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding()); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, true, ast); } if (binding != null) { ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, binding); for (int i= 0; i < typeProposals.length; i++) { addLinkedPositionProposal(key, typeProposals[i]); } return getImportRewrite().addImport(binding, ast); } return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$ }
public static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }
static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }
private static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isTypeVariable()) return containsTypeVariables(type.getTypeBounds()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }