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

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

Introduction

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

Prototype

long BeginAnnotationCheck

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

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);
            }//from  w  w  w .  j av  a 2 s  .  c o 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;
}