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

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

Introduction

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

Prototype

long AnnotationDeprecated

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

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryMember.java

License:Open Source License

protected IAnnotation[] getStandardAnnotations(long tagBits) {
    if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
        return Annotation.NO_ANNOTATIONS;
    ArrayList annotations = new ArrayList();

    if ((tagBits & TagBits.AnnotationTargetMASK) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_ANNOTATION_TARGET));
    }//from  ww w  .ja  v a  2s.c  om
    if ((tagBits & TagBits.AnnotationRetentionMASK) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_ANNOTATION_RETENTION));
    }
    if ((tagBits & TagBits.AnnotationDeprecated) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_DEPRECATED));
    }
    if ((tagBits & TagBits.AnnotationDocumented) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED));
    }
    if ((tagBits & TagBits.AnnotationInherited) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_ANNOTATION_INHERITED));
    }
    if ((tagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE));
    }
    if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
        annotations.add(getAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS));
    }
    // note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
    return (IAnnotation[]) annotations.toArray(new IAnnotation[annotations.size()]);
}

From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java

License:Open Source License

private void generateStandardAnnotationsInfos(JavaElement javaElement, char[] parameterName, long tagBits,
        HashMap newElements) {//from w  w  w  . j a  v  a2 s  . c om
    if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
        return;
    if ((tagBits & TagBits.AnnotationTargetMASK) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_TARGET,
                getTargetElementTypes(tagBits), newElements);
    }
    if ((tagBits & TagBits.AnnotationRetentionMASK) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_RETENTION,
                getRetentionPolicy(tagBits), newElements);
    }
    if ((tagBits & TagBits.AnnotationDeprecated) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_DEPRECATED,
                Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
    }
    if ((tagBits & TagBits.AnnotationDocumented) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED,
                Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
    }
    if ((tagBits & TagBits.AnnotationInherited) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_INHERITED,
                Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
    }
    if ((tagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        generateStandardAnnotation(javaElement,
                TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE,
                Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
    }
    if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
        generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_SAFEVARARGS,
                Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
    }
    // note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.BinaryIndexer.java

License:Open Source License

private void addBinaryStandardAnnotations(long annotationTagBits) {
    if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
        return;//from   ww  w.  j av  a 2 s . c om
    }
    if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
        addBinaryTargetAnnotation(annotationTagBits);
    }
    if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_RETENTION;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
        addBinaryRetentionAnnotation(annotationTagBits);
    }
    if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_DEPRECATED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationDocumented) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationInherited) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_INHERITED;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationOverride) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_OVERRIDE;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationSuppressWarnings) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SUPPRESSWARNINGS;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SAFEVARARGS;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
    if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
        addAnnotationTypeReference(compoundName[compoundName.length - 1]);
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.ClassFileMatchLocator.java

License:Open Source License

private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {
    if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
        return false;
    }//w ww  . j  a va2s  .c om
    if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)
                || ((annotationTagBits & TARGET_ANNOTATION_BITS) != 0
                        && checkAnnotationTypeReference(JAVA_LANG_ANNOTATION_ELEMENTTYPE, pattern))) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_RETENTION;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)
                || checkAnnotationTypeReference(
                        CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.'),
                        pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_DEPRECATED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationDocumented) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationInherited) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_INHERITED;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationOverride) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_OVERRIDE;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationSuppressWarnings) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SUPPRESSWARNINGS;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_SAFEVARARGS;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
        char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
        if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
            return true;
        }
    }
    return false;
}

From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java

License:Open Source License

public byte[] digest(IBinaryType classFile) {

    // type level comparison
    // modifiers/*w  w  w  .ja va  2 s.co  m*/
    updateInt(classFile.getModifiers());

    // only consider a portion of the tagbits which indicate a structural change for dependents
    // e.g. @Override change has no influence outside
    long OnlyStructuralTagBits = TagBits.AnnotationTargetMASK // different @Target status ?
            | TagBits.AnnotationDeprecated // different @Deprecated status ?
            | TagBits.AnnotationRetentionMASK // different @Retention status ?
            | TagBits.HierarchyHasProblems; // different hierarchy status ?

    // meta-annotations
    updateLong(classFile.getTagBits() & OnlyStructuralTagBits);
    // annotations
    updateAnnotations(classFile.getAnnotations());

    // generic signature
    updateChars(classFile.getGenericSignature());
    // superclass
    updateChars(classFile.getSuperclassName());
    // interfaces
    char[][] interfacesNames = classFile.getInterfaceNames();
    if (interfacesNames != null) {
        for (int i = 0; i < interfacesNames.length; i++) {
            updateChars(interfacesNames[i]);
        }
    }

    // member types
    IBinaryNestedType[] memberTypes = classFile.getMemberTypes();
    if (memberTypes != null) {
        for (int i = 0; i < memberTypes.length; i++) {
            updateChars(memberTypes[i].getName());
            updateInt(memberTypes[i].getModifiers());
        }
    }

    // fields
    FieldInfo[] fieldInfos = (FieldInfo[]) classFile.getFields();
    if (fieldInfos != null) {
        for (int i = 0; i < fieldInfos.length; i++) {
            updateField(fieldInfos[i]);
        }
    }

    // methods
    MethodInfo[] methodInfos = (MethodInfo[]) classFile.getMethods();
    if (methodInfos != null) {
        for (int i = 0; i < methodInfos.length; i++) {
            updateMethod(methodInfos[i]);
        }
    }

    // missing types
    char[][][] missingTypes = classFile.getMissingTypeNames();
    if (missingTypes != null) {
        for (int i = 0; i < missingTypes.length; i++) {
            for (int j = 0; j < missingTypes[i].length; j++) {
                if (j > 0) {
                    updateChar('.'); // don't ask why
                }
                updateChars(missingTypes[i][j]);
            }
        }
    }

    return digester.digest();
}

From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java

License:Open Source License

private void updateMethod(MethodInfo methodInfo) {
    // generic signature
    updateChars(methodInfo.getGenericSignature());
    updateInt(methodInfo.getModifiers());
    updateLong(methodInfo.getTagBits() & TagBits.AnnotationDeprecated);
    updateAnnotations(methodInfo.getAnnotations());
    // parameter annotations:
    for (int i = 0; i < methodInfo.getAnnotatedParametersCount(); i++) {
        updateAnnotations(methodInfo.getParameterAnnotations(i));
    }/*  w  w  w  . j a v  a  2s.  co  m*/

    updateChars(methodInfo.getSelector());
    updateChars(methodInfo.getMethodDescriptor());
    updateChars(methodInfo.getGenericSignature());

    char[][] thrownExceptions = methodInfo.getExceptionTypeNames();
    for (int i = 0; i < thrownExceptions.length; i++) {
        updateChars(thrownExceptions[i]);
    }
}

From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java

License:Open Source License

private void updateField(FieldInfo fieldInfo) {
    // generic signature
    updateChars(fieldInfo.getGenericSignature());
    updateInt(fieldInfo.getModifiers());
    updateLong(fieldInfo.getTagBits() & TagBits.AnnotationDeprecated);
    updateAnnotations(fieldInfo.getAnnotations());
    updateChars(fieldInfo.getName());//  ww  w.ja  v  a 2s . co m
    updateChars(fieldInfo.getTypeName());
    updateBoolean(fieldInfo.hasConstant());
    if (fieldInfo.hasConstant()) {
        updateConstant(fieldInfo.getConstant());
    }
}

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

License:Open Source License

/**
 * Compute the tagbits for standard annotations. For source types, these could require
 * lazily resolving corresponding annotation nodes, in case of forward references.
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#getAnnotationTagBits()
 *//*from www  .  j  a  v a2 s  . co  m*/
public long getAnnotationTagBits() {
    if ((this.tagBits & TagBits.AnnotationResolved) == 0 && this.scope != null) {
        TypeDeclaration typeDecl = this.scope.referenceContext;
        boolean old = typeDecl.staticInitializerScope.insideTypeAnnotation;
        try {
            typeDecl.staticInitializerScope.insideTypeAnnotation = true;
            ASTNode.resolveAnnotations(typeDecl.staticInitializerScope, typeDecl.annotations, this);
        } finally {
            typeDecl.staticInitializerScope.insideTypeAnnotation = old;
        }
        if ((this.tagBits & TagBits.AnnotationDeprecated) != 0)
            this.modifiers |= ClassFileConstants.AccDeprecated;
    }
    return this.tagBits;
}

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

License:Open Source License

/**
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#initializeDeprecatedAnnotationTagBits()
 *//*  www.  j a  v a 2 s .  c  o m*/
public void initializeDeprecatedAnnotationTagBits() {
    if ((this.tagBits & TagBits.DeprecatedAnnotationResolved) == 0) {
        TypeDeclaration typeDecl = this.scope.referenceContext;
        boolean old = typeDecl.staticInitializerScope.insideTypeAnnotation;
        try {
            typeDecl.staticInitializerScope.insideTypeAnnotation = true;
            ASTNode.resolveDeprecatedAnnotations(typeDecl.staticInitializerScope, typeDecl.annotations, this);
            this.tagBits |= TagBits.DeprecatedAnnotationResolved;
        } finally {
            typeDecl.staticInitializerScope.insideTypeAnnotation = old;
        }
        if ((this.tagBits & TagBits.AnnotationDeprecated) != 0) {
            this.modifiers |= ClassFileConstants.AccDeprecated;
        }
    }
}

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

License:Open Source License

public FieldBinding resolveTypeFor(FieldBinding field) {
    if ((field.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0)
        return field;

    if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
        if ((field.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0)
            field.modifiers |= ClassFileConstants.AccDeprecated;
    }/* w  ww  .j  av a  2 s .c  o m*/
    if (isViewedAsDeprecated() && !field.isDeprecated())
        field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
    if (hasRestrictedAccess())
        field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;
    FieldDeclaration[] fieldDecls = this.scope.referenceContext.fields;
    int length = fieldDecls == null ? 0 : fieldDecls.length;
    for (int f = 0; f < length; f++) {
        if (fieldDecls[f].binding != field)
            continue;

        MethodScope initializationScope = field.isStatic() ? this.scope.referenceContext.staticInitializerScope
                : this.scope.referenceContext.initializerScope;
        FieldBinding previousField = initializationScope.initializedField;
        try {
            initializationScope.initializedField = field;
            FieldDeclaration fieldDecl = fieldDecls[f];
            TypeBinding fieldType = fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT
                    ? initializationScope.environment().convertToRawType(this,
                            false /*do not force conversion of enclosing types*/) // enum constant is implicitly of declaring enum type
                    : fieldDecl.type.resolveType(initializationScope, true /* check bounds*/);
            field.type = fieldType;
            field.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
            if (fieldType == null) {
                fieldDecl.binding = null;
                return null;
            }
            if (fieldType == TypeBinding.VOID) {
                this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl);
                fieldDecl.binding = null;
                return null;
            }
            if (fieldType.isArrayType() && ((ArrayBinding) fieldType).leafComponentType == TypeBinding.VOID) {
                this.scope.problemReporter().variableTypeCannotBeVoidArray(fieldDecl);
                fieldDecl.binding = null;
                return null;
            }
            if ((fieldType.tagBits & TagBits.HasMissingType) != 0) {
                field.tagBits |= TagBits.HasMissingType;
            }
            TypeBinding leafType = fieldType.leafComponentType();
            if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers
                    & ExtraCompilerModifiers.AccGenericSignature) != 0) {
                field.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
            }
        } finally {
            initializationScope.initializedField = previousField;
        }
        return field;
    }
    return null; // should never reach this point
}