@Override public boolean visit(ParameterizedType createdType) { if (createdType == null || createdType.typeArguments().size() != 0) { return true; } ITypeBinding binding= createdType.resolveBinding(); if (binding == null) { return true; } ITypeBinding[] typeArguments= binding.getTypeArguments(); if (typeArguments.length == 0) { return true; } fNodes.add(createdType); return true; } }
@Override public boolean visit(ParameterizedType createdType) { if (createdType == null || createdType.typeArguments().size() != 0) { return true; } ITypeBinding binding= createdType.resolveBinding(); if (binding == null) { return true; } ITypeBinding[] typeArguments= binding.getTypeArguments(); if (typeArguments.length == 0) { return true; } fNodes.add(createdType); return true; } }
@Override public boolean visit(ParameterizedType createdType) { if (createdType == null || createdType.typeArguments().size() != 0) { return true; } ITypeBinding binding= createdType.resolveBinding(); if (binding == null) { return true; } ITypeBinding[] typeArguments= binding.getTypeArguments(); if (typeArguments.length == 0) { return true; } fNodes.add(createdType); return true; } }
private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration = (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type = (ParameterizedType) parent; return type.resolveBinding(); } return null; } }
private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; return type.resolveBinding(); } return null; } }
private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; return type.resolveBinding(); } return null; } }
/** * Returns the type binding of the class declaration node. * * @param parent * the node to get the type for * @return the type binding */ private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration = (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type = (ParameterizedType) parent; return type.resolveBinding(); } return null; }
/** * Returns the type binding of the class declaration node. * * @param parent the node to get the type for * @return the type binding */ private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; return type.resolveBinding(); } return null; }
/** * Returns the type binding of the class declaration node. * * @param parent the node to get the type for * @return the type binding */ private static ITypeBinding getTypeBinding(final ASTNode parent) { if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; return declaration.resolveBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; return type.resolveBinding(); } return null; }
public boolean visit(ParameterizedType node) { ITypeBinding binding = node.resolveBinding(); if (binding == null) return super.visit(node); coupleTo(binding); for (ITypeBinding types : binding.getTypeArguments()) { coupleTo(types); } return super.visit(node); }
/** * Returns the qualified type name of the class declaration. * * @return the qualified type name of the class */ private static String getQualifiedName(final ASTNode parent) { ITypeBinding binding= null; if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; binding= declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; final ClassInstanceCreation creation= (ClassInstanceCreation) declaration.getParent(); binding= creation.resolveTypeBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; binding= type.resolveBinding(); } if (binding != null) return binding.getBinaryName(); return null; }
/** * Returns the qualified type name of the class declaration. * * @return the qualified type name of the class */ private String getQualifiedName(final ASTNode parent) { ITypeBinding binding= null; if (parent instanceof AbstractTypeDeclaration) { final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) parent; binding= declaration.resolveBinding(); } else if (parent instanceof AnonymousClassDeclaration) { final AnonymousClassDeclaration declaration= (AnonymousClassDeclaration) parent; final ClassInstanceCreation creation= (ClassInstanceCreation) declaration.getParent(); binding= creation.resolveTypeBinding(); } else if (parent instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) parent; binding= type.resolveBinding(); } if (binding != null) return binding.getBinaryName(); return null; } }
ITypeBinding binding = createdType.resolveBinding(); if (binding != null) { ITypeBinding[] typeArguments = binding.getTypeArguments();
ITypeBinding binding= createdType.resolveBinding(); if (binding != null) { ITypeBinding[] typeArguments= binding.getTypeArguments();
@Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore model) throws CoreException { TextEditGroup group= createTextEditGroup(FixMessages.TypeParametersFix_insert_inferred_type_arguments_description, cuRewrite); ASTRewrite rewrite= cuRewrite.getASTRewrite(); ImportRewrite importRewrite= cuRewrite.getImportRewrite(); AST ast= cuRewrite.getRoot().getAST(); for (int i= 0; i < fCreatedTypes.length; i++) { ParameterizedType createdType= fCreatedTypes[i]; ITypeBinding[] typeArguments= createdType.resolveBinding().getTypeArguments(); ContextSensitiveImportRewriteContext importContext= new ContextSensitiveImportRewriteContext(cuRewrite.getRoot(), createdType.getStartPosition(), importRewrite); ListRewrite argumentsRewrite= rewrite.getListRewrite(createdType, ParameterizedType.TYPE_ARGUMENTS_PROPERTY); for (int j= 0; j < typeArguments.length; j++) { ITypeBinding typeArgument= typeArguments[j]; Type argumentNode= importRewrite.addImport(typeArgument, ast, importContext, TypeLocation.TYPE_ARGUMENT); argumentsRewrite.insertLast(argumentNode, group); } } } }
@Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model) throws CoreException { TextEditGroup group= createTextEditGroup(FixMessages.TypeParametersFix_insert_inferred_type_arguments_description, cuRewrite); ASTRewrite rewrite= cuRewrite.getASTRewrite(); ImportRewrite importRewrite= cuRewrite.getImportRewrite(); AST ast= cuRewrite.getRoot().getAST(); for (int i= 0; i < fCreatedTypes.length; i++) { ParameterizedType createdType= fCreatedTypes[i]; ITypeBinding[] typeArguments= createdType.resolveBinding().getTypeArguments(); ContextSensitiveImportRewriteContext importContext= new ContextSensitiveImportRewriteContext(cuRewrite.getRoot(), createdType.getStartPosition(), importRewrite); ListRewrite argumentsRewrite= rewrite.getListRewrite(createdType, ParameterizedType.TYPE_ARGUMENTS_PROPERTY); for (int j= 0; j < typeArguments.length; j++) { ITypeBinding typeArgument= typeArguments[j]; Type argumentNode= importRewrite.addImport(typeArgument, ast, importContext); argumentsRewrite.insertLast(argumentNode, group); } } } }
@Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model) throws CoreException { TextEditGroup group= createTextEditGroup(FixMessages.TypeParametersFix_insert_inferred_type_arguments_description, cuRewrite); ASTRewrite rewrite= cuRewrite.getASTRewrite(); ImportRewrite importRewrite= cuRewrite.getImportRewrite(); AST ast= cuRewrite.getRoot().getAST(); for (int i= 0; i < fCreatedTypes.length; i++) { ParameterizedType createdType= fCreatedTypes[i]; ITypeBinding[] typeArguments= createdType.resolveBinding().getTypeArguments(); ContextSensitiveImportRewriteContext importContext= new ContextSensitiveImportRewriteContext(cuRewrite.getRoot(), createdType.getStartPosition(), importRewrite); ListRewrite argumentsRewrite= rewrite.getListRewrite(createdType, ParameterizedType.TYPE_ARGUMENTS_PROPERTY); for (int j= 0; j < typeArguments.length; j++) { ITypeBinding typeArgument= typeArguments[j]; Type argumentNode= importRewrite.addImport(typeArgument, ast, importContext, TypeLocation.TYPE_ARGUMENT); argumentsRewrite.insertLast(argumentNode, group); } } } }
/** * The selection corresponds to a ParameterizedType (return type of method) */ private String parameterizedTypeSelected(ParameterizedType pt) { ASTNode parent= pt.getParent(); if (parent.getNodeType() == ASTNode.METHOD_DECLARATION){ fMethodBinding= ((MethodDeclaration)parent).resolveBinding(); fParamIndex= -1; fEffectiveSelectionStart= pt.getStartPosition(); fEffectiveSelectionLength= pt.getLength(); setOriginalType(pt.resolveBinding()); } else if (parent.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION){ return singleVariableDeclarationSelected((SingleVariableDeclaration)parent); } else if (parent.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT){ return variableDeclarationStatementSelected((VariableDeclarationStatement)parent); } else if (parent.getNodeType() == ASTNode.FIELD_DECLARATION){ return fieldDeclarationSelected((FieldDeclaration)parent); } else { return nodeTypeNotSupported(); } return null; }
/** * The selection corresponds to a ParameterizedType (return type of method) * @param pt the type * @return the message */ private String parameterizedTypeSelected(ParameterizedType pt) { ASTNode parent= pt.getParent(); if (parent.getNodeType() == ASTNode.METHOD_DECLARATION){ fMethodBinding= ((MethodDeclaration)parent).resolveBinding(); fParamIndex= -1; fEffectiveSelectionStart= pt.getStartPosition(); fEffectiveSelectionLength= pt.getLength(); setOriginalType(pt.resolveBinding()); } else if (parent.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION){ return singleVariableDeclarationSelected((SingleVariableDeclaration)parent); } else if (parent.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT){ return variableDeclarationStatementSelected((VariableDeclarationStatement)parent); } else if (parent.getNodeType() == ASTNode.FIELD_DECLARATION){ return fieldDeclarationSelected((FieldDeclaration)parent); } else { return nodeTypeNotSupported(); } return null; }
/** * The selection corresponds to a ParameterizedType (return type of method) * @param pt the type * @return the message */ private String parameterizedTypeSelected(ParameterizedType pt) { ASTNode parent= pt.getParent(); if (parent.getNodeType() == ASTNode.METHOD_DECLARATION){ fMethodBinding= ((MethodDeclaration)parent).resolveBinding(); fParamIndex= -1; fEffectiveSelectionStart= pt.getStartPosition(); fEffectiveSelectionLength= pt.getLength(); setOriginalType(pt.resolveBinding()); } else if (parent.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION){ return singleVariableDeclarationSelected((SingleVariableDeclaration)parent); } else if (parent.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT){ return variableDeclarationStatementSelected((VariableDeclarationStatement)parent); } else if (parent.getNodeType() == ASTNode.FIELD_DECLARATION){ return fieldDeclarationSelected((FieldDeclaration)parent); } else { return nodeTypeNotSupported(); } return null; }