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 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; }
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 arguments, ITypeBinding[] argTypes) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; for (int i= 0; i < nDiffs; i++) { int diffIndex= indexOfDiff[i]; Expression arg= (Expression) arguments.get(diffIndex); String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null; 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; }
private static ChangeDescription[] createSignatureChangeDescription(int[] indexOfDiff, int nDiffs, ITypeBinding[] paramTypes, List arguments, ITypeBinding[] argTypes) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; for (int i= 0; i < nDiffs; i++) { int diffIndex= indexOfDiff[i]; Expression arg= (Expression) arguments.get(diffIndex); String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null; 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; }
public AssignToVariableAssistProposal(ICompilationUnit cu, int variableKind, ExpressionStatement node, ITypeBinding typeBinding, int relevance) { super("", cu, null, relevance, null); //$NON-NLS-1$ fVariableKind= variableKind; fNodesToAssign= new ArrayList<>(); fNodesToAssign.add(node); if (typeBinding.isWildcardType()) { typeBinding= ASTResolving.normalizeWildcardType(typeBinding, true, node.getAST()); } fTypeBinding= typeBinding; if (variableKind == LOCAL) { setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntolocal_description); setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL)); } else { setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntofield_description); setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE)); } createImportRewrite((CompilationUnit) node.getRoot()); }
public static ITypeBinding guessBindingForTypeReference(ASTNode node) { StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) { return null; // can't guess type for X.A } if (locationInParent == SimpleType.NAME_PROPERTY) { node= node.getParent(); } ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node)); if (binding != null) { if (binding.isWildcardType()) { return normalizeWildcardType(binding, true, node.getAST()); } } return binding; }
public static ITypeBinding guessBindingForTypeReference(ASTNode node) { StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) { return null; // can't guess type for X.A } if (locationInParent == SimpleType.NAME_PROPERTY || locationInParent == NameQualifiedType.NAME_PROPERTY) { node= node.getParent(); } ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node)); if (binding != null) { if (binding.isWildcardType()) { return normalizeWildcardType(binding, true, node.getAST()); } } return binding; }
/** * Returns the iterable type from the iterator type binding. * * @param iterator * the iterator type binding, or <code>null</code> * @return the iterable type */ private ITypeBinding getIterableType(final ITypeBinding iterator) { if (iterator != null) { final ITypeBinding[] bindings= iterator.getTypeArguments(); if (bindings.length > 0) { ITypeBinding arg= bindings[0]; if (arg.isWildcardType()) { arg= ASTResolving.normalizeWildcardType(arg, true, getRoot().getAST()); } return arg; } } return getRoot().getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ }
/** * Returns the type of elements returned by the iterator. * * @param iterator * the iterator type binding, or <code>null</code> * @return the element type */ private ITypeBinding getElementType(final ITypeBinding iterator) { if (iterator != null) { final ITypeBinding[] bindings= iterator.getTypeArguments(); if (bindings.length > 0) { ITypeBinding arg= bindings[0]; if (arg.isWildcardType()) { arg= ASTResolving.normalizeWildcardType(arg, true, getRoot().getAST()); } return arg; } } return getRoot().getAST().resolveWellKnownType("java.lang.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 AssignToVariableAssistProposal(ICompilationUnit cu, int variableKind, ExpressionStatement node, ITypeBinding typeBinding, int relevance) { super("", cu, null, relevance, null); //$NON-NLS-1$ fVariableKind= variableKind; fNodeToAssign= node; if (typeBinding.isWildcardType()) { typeBinding= ASTResolving.normalizeWildcardType(typeBinding, true, node.getAST()); } fTypeBinding= typeBinding; if (variableKind == LOCAL) { setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntolocal_description); setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL)); } else { setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntofield_description); setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE)); } createImportRewrite((CompilationUnit) node.getRoot()); }
binding= ASTResolving.normalizeWildcardType(binding, true, ast);
typeBinding= ASTResolving.normalizeWildcardType(typeBinding, true, ast);
if (binding != null) { if (binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, isVariableAssigned(), ast); if (binding == null) {
if (binding != null) { if (binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, isVariableAssigned(), ast); if (binding == null) {
ITypeBinding binding= ASTResolving.guessBindingForReference(node); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, false, ast);
ITypeBinding binding= ASTResolving.guessBindingForReference(node); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, false, ast);