String fqn = getFqn(typeDef); if (fqn != null && (fqn.equals(INT_DEF_ANNOTATION) ||
boolean match = false; for (Annotation typeDef : typeDefs) { String fqn = getFqn(typeDef); if (isNestedAnnotation(fqn)) { List<AnnotationData> list = types.get(typeName);
private boolean isRelevantAnnotation(@NonNull Annotation annotation) { String fqn = getFqn(annotation); if (fqn == null || fqn.startsWith("java.lang.")) { return false; } if (fqn.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) { if (fqn.equals(SUPPORT_KEEP)) { return true; // even with class file retention we want to process these } //noinspection PointlessBooleanExpression,ConstantConditions,RedundantIfStatement if (!includeClassRetentionAnnotations && !hasSourceRetention(fqn, annotation)) { return false; } return true; } else if (fqn.startsWith(ANDROID_ANNOTATIONS_PREFIX)) { return isRelevantFrameworkAnnotation(fqn); } if (fqn.equals(ANDROID_NULLABLE) || fqn.equals(ANDROID_NOTNULL) || isMagicConstant(fqn)) { return true; } else if (fqn.equals(IDEA_CONTRACT)) { return true; } return false; }
private boolean isRelevantAnnotation(@NonNull Annotation annotation) { String fqn = getFqn(annotation); if (fqn == null || fqn.startsWith("java.lang.")) { return false; } if (fqn.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) { if (fqn.equals(SUPPORT_KEEP)) { return true; // even with class file retention we want to process these } //noinspection PointlessBooleanExpression,ConstantConditions,RedundantIfStatement if (!includeClassRetentionAnnotations && !hasSourceRetention(fqn, annotation)) { return false; } return true; } else if (fqn.startsWith(ANDROID_ANNOTATIONS_PREFIX)) { return isRelevantFrameworkAnnotation(fqn); } if (fqn.equals(ANDROID_NULLABLE) || fqn.equals(ANDROID_NOTNULL) || isMagicConstant(fqn)) { return true; } else if (fqn.equals(IDEA_CONTRACT)) { return true; } return false; }
@Nullable private static String getFqn(@NonNull MethodScope scope) { ClassScope classScope = findClassScope(scope); if (classScope != null) { return getFqn(classScope); } return null; }
@SuppressWarnings("unused") static boolean hasSourceRetention(@NonNull Annotation[] annotations) { for (Annotation annotation : annotations) { String typeName = Extractor.getFqn(annotation); if ("java.lang.annotation.Retention".equals(typeName)) { MemberValuePair[] pairs = annotation.memberValuePairs(); if (pairs == null || pairs.length != 1) { warning("Expected exactly one parameter passed to @Retention"); return false; } MemberValuePair pair = pairs[0]; Expression value = pair.value; if (value instanceof NameReference) { NameReference reference = (NameReference) value; Binding binding = reference.binding; if (binding != null) { if (binding instanceof FieldBinding) { FieldBinding fb = (FieldBinding) binding; if ("SOURCE".equals(new String(fb.name)) && "java.lang.annotation.RetentionPolicy".equals( new String(fb.declaringClass.readableName()))) { return true; } } } } } } return false; }
@Nullable private static String getFqn(@NonNull MethodScope scope) { ClassScope classScope = findClassScope(scope); if (classScope != null) { return getFqn(classScope); } return null; }
@Nullable private static String getFqn(@NonNull BlockScope scope) { ClassScope classScope = findClassScope(scope); if (classScope != null) { return getFqn(classScope); } return null; }
@Nullable private static String getFqn(@NonNull BlockScope scope) { ClassScope classScope = findClassScope(scope); if (classScope != null) { return getFqn(classScope); } return null; }
@SuppressWarnings("unused") static boolean hasSourceRetention(@NonNull Annotation[] annotations) { for (Annotation annotation : annotations) { String typeName = Extractor.getFqn(annotation); if ("java.lang.annotation.Retention".equals(typeName)) { MemberValuePair[] pairs = annotation.memberValuePairs(); if (pairs == null || pairs.length != 1) { warning("Expected exactly one parameter passed to @Retention"); return false; } MemberValuePair pair = pairs[0]; Expression value = pair.value; if (value instanceof NameReference) { NameReference reference = (NameReference) value; Binding binding = reference.binding; if (binding != null) { if (binding instanceof FieldBinding) { FieldBinding fb = (FieldBinding) binding; if ("SOURCE".equals(new String(fb.name)) && "java.lang.annotation.RetentionPolicy".equals( new String(fb.declaringClass.readableName()))) { return true; } } } } } } return false; }
private void addAnnotations(@Nullable Annotation[] annotations, @NonNull Item item) { if (annotations != null) { for (Annotation annotation : annotations) { if (isRelevantAnnotation(annotation)) { String fqn = getFqn(annotation); if (SUPPORT_KEEP.equals(fqn)) { // Put keep rules in a different place; we don't want to write // these out into the external annotations database, they go // into a special proguard file keepItems.add(item); } else { addAnnotation(annotation, fqn, item.annotations); } } } } }
if (declaration.binding.isAnnotationType()) { for (Annotation annotation : annotations) { String typeName = Extractor.getFqn(annotation); if (typeName == null) { continue;
if (declaration.binding.isAnnotationType()) { for (Annotation annotation : annotations) { String typeName = Extractor.getFqn(annotation); if (typeName == null) { continue;
@Nullable private AnnotationData createAnnotation(@NonNull Annotation annotation) { String fqn = getFqn(annotation); if (fqn == null) { return null;