private static Set<String> getSuppressed(List<CustomAnnotation> annos) { Set<String> filters = null; for (CustomAnnotation ca : annos) { String name = ca.getAnnotationType().getSimpleName(); if (!(name.startsWith("Suppress") && name.endsWith("Warning"))) continue; for (AnnotationParameter par : ca.getParameters()) { if (par.getMember().equals("value")) { AnnotationElement ae = par.getValue(); AnnotationElement[] elements = ae instanceof ArrayAnnotationElement ? ((ArrayAnnotationElement) ae) .getElements() : new AnnotationElement[] { ae }; for (AnnotationElement child : elements) { if (child instanceof ConstantAnnotationElement) { Object value = ((ConstantAnnotationElement) child).getConstantValue(); if (value instanceof String) { if (filters == null) filters = new HashSet<>(); filters.add((String) value); } } } } } } return filters == null ? Collections.emptySet() : filters; }
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }
@Override protected void visitType(TypeDefinition td) { if (!td.isAnnotation()) return; DeclaredAnnotation da = getOrCreate(td); for (CustomAnnotation ca : td.getAnnotations()) { if (Types.is(ca.getAnnotationType(), Retention.class)) { for (AnnotationParameter ap : ca.getParameters()) { if (ap.getMember().equals("value")) { AnnotationElement value = ap.getValue(); if (value instanceof EnumAnnotationElement) { EnumAnnotationElement enumValue = (EnumAnnotationElement) value; if (Types.is(enumValue.getEnumType(), RetentionPolicy.class)) { da.policy = RetentionPolicy.valueOf(enumValue.getEnumConstantName()); } } } } } } }
public Expression createAnnotationElement(final AnnotationElement element) { switch (element.getElementType()) { case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue()); return new TypeReferenceExpression(Expression.MYSTERY_OFFSET, convertType(enumElement.getEnumType())).member(enumElement.getEnumConstantName()); final AstNodeCollection<Expression> elements = initializer.getElements(); for (final AnnotationElement e : arrayElement.getElements()) { elements.add(createAnnotationElement(e)); return new ClassOfExpression( Expression.MYSTERY_OFFSET, convertType(((ClassAnnotationElement) element).getClassType()) ); return createAnnotation(((AnnotationAnnotationElement) element).getAnnotation());
private static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); elements[i] = readElement(scope, input); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); final CustomAnnotation annotation = read(scope, input); return new AnnotationAnnotationElement(annotation);
public static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); return new AnnotationAnnotationElement(annotation);
public static CustomAnnotation read(final IMetadataScope scope, final Buffer input) { final int typeToken = input.readUnsignedShort(); final int parameterCount = input.readUnsignedShort(); final TypeReference annotationType = scope.lookupType(typeToken); final AnnotationParameter[] parameters = new AnnotationParameter[parameterCount]; readParameters(parameters, scope, input, true); return new CustomAnnotation(annotationType, ArrayUtilities.asUnmodifiableList(parameters)); }
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }
public Expression createAnnotationElement(final AnnotationElement element) { switch (element.getElementType()) { case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue()); return new TypeReferenceExpression(Expression.MYSTERY_OFFSET, convertType(enumElement.getEnumType())).member(enumElement.getEnumConstantName()); final AstNodeCollection<Expression> elements = initializer.getElements(); for (final AnnotationElement e : arrayElement.getElements()) { elements.add(createAnnotationElement(e)); return new ClassOfExpression( Expression.MYSTERY_OFFSET, convertType(((ClassAnnotationElement) element).getClassType()) ); return createAnnotation(((AnnotationAnnotationElement) element).getAnnotation());
private static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); elements[i] = readElement(scope, input); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); final CustomAnnotation annotation = read(scope, input); return new AnnotationAnnotationElement(annotation);
public static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); return new AnnotationAnnotationElement(annotation);
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }
public static CustomAnnotation read(final IMetadataScope scope, final Buffer input) { final int typeToken = input.readUnsignedShort(); final int parameterCount = input.readUnsignedShort(); final TypeReference annotationType = scope.lookupType(typeToken); final AnnotationParameter[] parameters = new AnnotationParameter[parameterCount]; readParameters(parameters, scope, input, true); return new CustomAnnotation(annotationType, ArrayUtilities.asUnmodifiableList(parameters)); }
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }
public Expression createAnnotationElement(final AnnotationElement element) { switch (element.getElementType()) { case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue()); return new TypeReferenceExpression(Expression.MYSTERY_OFFSET, convertType(enumElement.getEnumType())).member(enumElement.getEnumConstantName()); final AstNodeCollection<Expression> elements = initializer.getElements(); for (final AnnotationElement e : arrayElement.getElements()) { elements.add(createAnnotationElement(e)); return new ClassOfExpression( Expression.MYSTERY_OFFSET, convertType(((ClassAnnotationElement) element).getClassType()) ); return createAnnotation(((AnnotationAnnotationElement) element).getAnnotation());
private static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); elements[i] = readElement(scope, input); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); final CustomAnnotation annotation = read(scope, input); return new AnnotationAnnotationElement(annotation);
public static AnnotationElement readElement(final IMetadataScope scope, final Buffer input) { final char tag = (char) input.readUnsignedByte(); final AnnotationElementType elementType = AnnotationElementType.forTag(tag); return new ConstantAnnotationElement(constantValue); final TypeReference enumType = scope.lookupType(input.readUnsignedShort()); final String constantName = scope.lookupConstant(input.readUnsignedShort()); return new EnumAnnotationElement(enumType, constantName); return new ArrayAnnotationElement(elements); return new ClassAnnotationElement(type); return new AnnotationAnnotationElement(annotation);
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }
public static CustomAnnotation read(final IMetadataScope scope, final Buffer input) { final int typeToken = input.readUnsignedShort(); final int parameterCount = input.readUnsignedShort(); final TypeReference annotationType = scope.lookupType(typeToken); final AnnotationParameter[] parameters = new AnnotationParameter[parameterCount]; readParameters(parameters, scope, input, true); return new CustomAnnotation(annotationType, ArrayUtilities.asUnmodifiableList(parameters)); }
private static void readParameters( final AnnotationParameter[] parameters, final IMetadataScope scope, final Buffer input, final boolean namedParameter) { for (int i = 0; i < parameters.length; i++) { parameters[i] = new AnnotationParameter( namedParameter ? scope.<String>lookupConstant(input.readUnsignedShort()) : "value", readElement(scope, input) ); } }