Example usage for org.eclipse.jdt.internal.compiler.lookup TagBits EndAnnotationCheck

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TagBits EndAnnotationCheck

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup TagBits EndAnnotationCheck.

Prototype

long EndAnnotationCheck

To view the source code for org.eclipse.jdt.internal.compiler.lookup TagBits EndAnnotationCheck.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java

License:Open Source License

public boolean detectAnnotationCycle() {
    if ((this.tagBits & TagBits.EndAnnotationCheck) != 0)
        return false; // already checked
    if ((this.tagBits & TagBits.BeginAnnotationCheck) != 0)
        return true; // in the middle of checking its methods

    this.tagBits |= TagBits.BeginAnnotationCheck;
    MethodBinding[] currentMethods = methods();
    boolean inCycle = false; // check each method before failing
    for (int i = 0, l = currentMethods.length; i < l; i++) {
        TypeBinding returnType = currentMethods[i].returnType.leafComponentType().erasure();
        if (this == returnType) {
            if (this instanceof SourceTypeBinding) {
                MethodDeclaration decl = (MethodDeclaration) currentMethods[i].sourceMethod();
                ((SourceTypeBinding) this).scope.problemReporter().annotationCircularity(this, this,
                        decl != null ? decl.returnType : null);
            }//w  w w. j  ava2  s.  co m
        } else if (returnType.isAnnotationType() && ((ReferenceBinding) returnType).detectAnnotationCycle()) {
            if (this instanceof SourceTypeBinding) {
                MethodDeclaration decl = (MethodDeclaration) currentMethods[i].sourceMethod();
                ((SourceTypeBinding) this).scope.problemReporter().annotationCircularity(this, returnType,
                        decl != null ? decl.returnType : null);
            }
            inCycle = true;
        }
    }
    if (inCycle)
        return true;
    this.tagBits |= TagBits.EndAnnotationCheck;
    return false;
}