private void annotateList(List annotations, IAnnotationBinding [] annotationBindings, AST ast, ImportRewriteContext context, TypeLocation location, ITypeBinding type) { if (context == null) context= this.defaultContext; annotationBindings = context.removeRedundantTypeAnnotations(annotationBindings, location, type); for (int i = 0; i< annotationBindings.length; i++) { Annotation annotation = addAnnotation(annotationBindings[i], ast, context); if (annotation != null) annotations.add(annotation); } }
private void annotateList(List annotations, IAnnotationBinding [] annotationBindings, AST ast, ImportRewriteContext context, TypeLocation location, ITypeBinding type) { if (context == null) context= this.defaultContext; annotationBindings = context.removeRedundantTypeAnnotations(annotationBindings, location, type); for (int i = 0; i< annotationBindings.length; i++) { Annotation annotation = addAnnotation(annotationBindings[i], ast, context); if (annotation != null) annotations.add(annotation); } }
/** * Create a Type suitable as the creationType in a ClassInstanceCreation expression. * @param ast The AST to create the nodes for. * @param typeBinding binding representing the given class type * @param importRewrite the import rewrite to use * @param importContext the import context used to determine which (null) annotations to consider * @return a Type suitable as the creationType in a ClassInstanceCreation expression. */ public static Type newCreationType(AST ast, ITypeBinding typeBinding, ImportRewrite importRewrite, ImportRewriteContext importContext) { if (typeBinding.isParameterizedType()) { Type baseType= newCreationType(ast, typeBinding.getTypeDeclaration(), importRewrite, importContext); IAnnotationBinding[] typeAnnotations= importContext.removeRedundantTypeAnnotations(typeBinding.getTypeAnnotations(), TypeLocation.NEW, typeBinding); for (IAnnotationBinding typeAnnotation : typeAnnotations) { ((AnnotatableType)baseType).annotations().add(importRewrite.addAnnotation(typeAnnotation, ast, importContext)); } ParameterizedType parameterizedType= ast.newParameterizedType(baseType); for (ITypeBinding typeArgument : typeBinding.getTypeArguments()) { typeArgument= StubUtility2Core.replaceWildcardsAndCaptures(typeArgument); parameterizedType.typeArguments().add(importRewrite.addImport(typeArgument, ast, importContext, TypeLocation.TYPE_ARGUMENT)); } return parameterizedType; } else { return importRewrite.addImport(typeBinding, ast, importContext, TypeLocation.NEW); } } }
@Override public IAnnotationBinding[] removeRedundantTypeAnnotations(IAnnotationBinding[] annotations, TypeLocation location, ITypeBinding type) { RedundantNullnessTypeAnnotationsFilter redundantTypeAnnotationsFilter= fRedundantTypeAnnotationsFilter; if (redundantTypeAnnotationsFilter != null) { annotations= redundantTypeAnnotationsFilter.removeUnwantedTypeAnnotations(annotations, location, type); } return super.removeRedundantTypeAnnotations(annotations, location, type); } }