Example usage for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding isViewedAsDeprecated

List of usage examples for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding isViewedAsDeprecated

Introduction

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

Prototype

public final boolean isViewedAsDeprecated() 

Source Link

Document

Answer true if the receiver is deprecated (or any of its enclosing types)

Usage

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

License:Open Source License

public boolean isInsideDeprecatedCode() {
    switch (this.kind) {
    case Scope.BLOCK_SCOPE:
    case Scope.METHOD_SCOPE:
        MethodScope methodScope = methodScope();
        if (!methodScope.isInsideInitializer()) {
            // check method modifiers to see if deprecated
            MethodBinding context = ((AbstractMethodDeclaration) methodScope.referenceContext).binding;
            if (context != null && context.isViewedAsDeprecated())
                return true;
        } else if (methodScope.initializedField != null
                && methodScope.initializedField.isViewedAsDeprecated()) {
            // inside field declaration ? check field modifier to see if deprecated
            return true;
        }/*from   w  w  w.  ja v  a 2  s  .  c  o m*/
        SourceTypeBinding declaringType = ((BlockScope) this).referenceType().binding;
        if (declaringType != null) {
            declaringType.initializeDeprecatedAnnotationTagBits(); // may not have been resolved until then
            if (declaringType.isViewedAsDeprecated())
                return true;
        }
        break;
    case Scope.CLASS_SCOPE:
        ReferenceBinding context = ((ClassScope) this).referenceType().binding;
        if (context != null) {
            context.initializeDeprecatedAnnotationTagBits(); // may not have been resolved until then
            if (context.isViewedAsDeprecated())
                return true;
        }
        break;
    case Scope.COMPILATION_UNIT_SCOPE:
        // consider import as being deprecated if first type is itself deprecated (123522)
        CompilationUnitDeclaration unit = referenceCompilationUnit();
        if (unit.types != null && unit.types.length > 0) {
            SourceTypeBinding type = unit.types[0].binding;
            if (type != null) {
                type.initializeDeprecatedAnnotationTagBits(); // may not have been resolved until then
                if (type.isViewedAsDeprecated())
                    return true;
            }
        }
    }
    return false;
}