public void checkRepeatableMetaAnnotation(BlockScope scope) { // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site. ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here MemberValuePair[] valuePairs = this.memberValuePairs(); if (valuePairs == null || valuePairs.length != 1) return; Object value = valuePairs[0].compilerElementPair.value; if (!(value instanceof ReferenceBinding)) return; // Has deeper problems, will bark elsewhere. ReferenceBinding containerAnnotationType = (ReferenceBinding) value; if (!containerAnnotationType.isAnnotationType()) return; // Has deeper problems, will bark elsewhere. repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems. checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested. }
private boolean internalVisit(Annotation annotation) { if (annotation.getCompilerAnnotation() == m_binding) { m_result = annotation; } return m_result == null; } }
for (Annotation annotation : type.annotations[position]) { if (scope instanceof ClassScope) { annotation.traverse(this.jdtTreeBuilder, (ClassScope) scope); } else if (scope instanceof BlockScope) { annotation.traverse(this.jdtTreeBuilder, (BlockScope) scope); } else { annotation.traverse(this.jdtTreeBuilder, (BlockScope) null);
MethodBinding[] methods = annotationType.methods(); MemberValuePair[] originalValuePairs = memberValuePairs(); this.compilerAnnotation = scope.environment().createAnnotation((ReferenceBinding) this.resolvedType, computeElementValuePairs()); long tagBits = detectStandardAnnotation(scope, annotationType, valueAttribute); start = typeDeclaration.declarationSourceStart; recordSuppressWarnings(scope, start, typeDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); sourceType = (SourceTypeBinding) sourceMethod.declaringClass; AbstractMethodDeclaration methodDeclaration = sourceType.scope.referenceContext.declarationOf(sourceMethod); recordSuppressWarnings(scope, methodDeclaration.declarationSourceStart, methodDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); sourceType = (SourceTypeBinding) sourceField.declaringClass; FieldDeclaration fieldDeclaration = sourceType.scope.referenceContext.declarationOf(sourceField); recordSuppressWarnings(scope, fieldDeclaration.declarationSourceStart, fieldDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) { LocalDeclaration localDeclaration = variable.declaration; recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings);
annotations[j] = sourceAnnotations[j].getCompilerAnnotation(); annotations[j] = annot.getCompilerAnnotation(); for (int j = 0; j < length; j++) { Annotation annot = sourceAnnotations[j]; annotations[j] = annot.getCompilerAnnotation(); AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); annotations[j] = annotationBinding; if (annotationBinding != null) { final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); } else { annotation.recipient = recipient; annotation.resolveType(scope); annotations[i] = annotation.getCompilerAnnotation(); ReferenceBinding annotationType = annotations[i] != null ? annotations[i].getAnnotationType() : null; if (annotationType != null && annotationType.id == TypeIds.T_JavaLangAnnotationRepeatable) annotation.checkRepeatableMetaAnnotation(scope); Annotation persistibleAnnotation = sourceAnnotations[i].getPersistibleAnnotation(); if (persistibleAnnotation instanceof ContainerAnnotation) container = (ContainerAnnotation) persistibleAnnotation;
annotations[j] = annot.getCompilerAnnotation(); for (int j = 0; j < length; j++) { Annotation annot = sourceAnnotations[j]; annotations[j] = annot.getCompilerAnnotation(); AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); annotations[j] = annotationBinding; if (annotationBinding != null) { final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); } else { annotation.recipient = recipient; annotation.resolveType(scope); annotations[i] = annotation.getCompilerAnnotation();
annotations[0] = annotation.getCompilerAnnotation(); for (int j = 1; j < length; j++) { Annotation annot = sourceAnnotations[j]; annotations[j] = annot.getCompilerAnnotation(); } else { annotation.recipient = recipient; annotation.resolveType(scope); annotations[i] = annotation.getCompilerAnnotation();
public int match(Annotation node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; MemberValuePair[] pairs = node.memberValuePairs(); if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH; int length = pairs.length; MemberValuePair pair = null; for (int i=0; i<length; i++) { pair = node.memberValuePairs()[i]; if (matchesName(this.pattern.selector, pair.name)) { ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair; return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); } } return IMPOSSIBLE_MATCH; } //public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
@Override public StringBuffer printExpression(int indent, StringBuffer output) { super.printExpression(indent, output); output.append('('); this.memberValue.printExpression(indent, output); return output.append(')'); }
@Override public StringBuffer print(int indent, StringBuffer output) { return this.annotations[0].print(indent, output); } }
AnnotationBinding(Annotation astAnnotation) { this((ReferenceBinding) astAnnotation.resolvedType, astAnnotation.computeElementValuePairs()); }
utf8Offset = this.constantPoolOffsets[u2At(currentOffset)] - this.structOffset; char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); this.standardAnnotationTagBits |= Annotation.getRetentionPolicy(constName);
utf8Offset = this.constantPoolOffsets[u2At(currentOffset)] - this.structOffset; char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); this.standardAnnotationTagBits |= Annotation.getTargetElementType(constName);
MethodBinding[] methods = annotationType.methods(); MemberValuePair[] originalValuePairs = memberValuePairs(); this.compilerAnnotation = scope.environment().createAnnotation((ReferenceBinding) this.resolvedType, computeElementValuePairs()); long tagBits = detectStandardAnnotation(scope, annotationType, valueAttribute); int defaultNullness = (int)(tagBits & Binding.NullnessDefaultMASK); tagBits &= ~Binding.NullnessDefaultMASK; start = typeDeclaration.declarationSourceStart; recordSuppressWarnings(scope, start, typeDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); sourceType = (SourceTypeBinding) sourceMethod.declaringClass; AbstractMethodDeclaration methodDeclaration = sourceType.scope.referenceContext.declarationOf(sourceMethod); recordSuppressWarnings(scope, methodDeclaration.declarationSourceStart, methodDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); sourceType = (SourceTypeBinding) sourceField.declaringClass; FieldDeclaration fieldDeclaration = sourceType.scope.referenceContext.declarationOf(sourceField); recordSuppressWarnings(scope, fieldDeclaration.declarationSourceStart, fieldDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); kind = Binding.PACKAGE; checkAnnotationTarget(this, scope, annotationType, kind, this.recipient, tagBits & TagBits.AnnotationNullMASK);
annotations[j] = sourceAnnotations[j].getCompilerAnnotation(); annotations[j] = annot.getCompilerAnnotation(); for (int j = 0; j < length; j++) { Annotation annot = sourceAnnotations[j]; annotations[j] = annot.getCompilerAnnotation(); AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); annotations[j] = annotationBinding; if (annotationBinding != null) { final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); } else { annotation.recipient = recipient; annotation.resolveType(scope); annotations[i] = annotation.getCompilerAnnotation(); ReferenceBinding annotationType = annotations[i] != null ? annotations[i].getAnnotationType() : null; if (annotationType != null && annotationType.id == TypeIds.T_JavaLangAnnotationRepeatable) annotation.checkRepeatableMetaAnnotation(scope); Annotation persistibleAnnotation = sourceAnnotations[i].getPersistibleAnnotation(); if (persistibleAnnotation instanceof ContainerAnnotation) container = (ContainerAnnotation) persistibleAnnotation;
annotations[j] = annot.getCompilerAnnotation(); for (int j = 0; j < length; j++) { Annotation annot = sourceAnnotations[j]; annotations[j] = annot.getCompilerAnnotation(); AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); annotations[j] = annotationBinding; if (annotationBinding != null) { final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); } else { annotation.recipient = recipient; annotation.resolveType(scope); annotations[i] = annotation.getCompilerAnnotation();
AnnotationBinding compilerAnnotation = annotation.getCompilerAnnotation(); if (compilerAnnotation == null) { annotation.resolveType(scopeForTypeLookup.referenceContext.staticInitializerScope); return annotation.getCompilerAnnotation();
public int match(Annotation node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; MemberValuePair[] pairs = node.memberValuePairs(); if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH; int length = pairs.length; MemberValuePair pair = null; for (int i=0; i<length; i++) { pair = node.memberValuePairs()[i]; if (matchesName(this.pattern.selector, pair.name)) { ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair; return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); } } return IMPOSSIBLE_MATCH; } //public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
public StringBuffer printExpression(int indent, StringBuffer output) { super.printExpression(indent, output); output.append('('); this.memberValue.printExpression(indent, output); return output.append(')'); }
public StringBuffer print(int indent, StringBuffer output) { return this.annotations[0].print(indent, output); } }