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

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

Introduction

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

Prototype

long AnnotationPolymorphicSignature

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

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   www.j a v a  2s. com*/
    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  www  . j ava2 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  a  v a  2s  . c  o  m
    }
    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;
    }/*from   ww  w  .  j a v a 2s.  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:org.eclipse.jdt.internal.compiler.lookup.Scope.java

License:Open Source License

/**
 * Internal use only//ww w .  j a va 2s  .  c  o  m
 * Given a method, returns null if arguments cannot be converted to parameters.
 * Will answer a substituted method in case the method was generic and type inference got triggered;
 * in case the method was originally compatible, then simply answer it back.
 */
protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments,
        InvocationSite invocationSite) {
    TypeBinding[] genericTypeArguments = invocationSite.genericTypeArguments();
    TypeBinding[] parameters = method.parameters;
    TypeVariableBinding[] typeVariables = method.typeVariables;
    if (parameters == arguments && (method.returnType.tagBits & TagBits.HasTypeVariable) == 0
            && genericTypeArguments == null && typeVariables == Binding.NO_TYPE_VARIABLES)
        return method;

    int argLength = arguments.length;
    int paramLength = parameters.length;
    boolean isVarArgs = method.isVarargs();
    if (argLength != paramLength)
        if (!isVarArgs || argLength < paramLength - 1)
            return null; // incompatible

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330435, inference should kick in only at source 1.5+
    if (typeVariables != Binding.NO_TYPE_VARIABLES
            && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // generic method
        TypeBinding[] newArgs = null;
        for (int i = 0; i < argLength; i++) {
            TypeBinding param = i < paramLength ? parameters[i] : parameters[paramLength - 1];
            if (arguments[i].isBaseType() != param.isBaseType()) {
                if (newArgs == null) {
                    newArgs = new TypeBinding[argLength];
                    System.arraycopy(arguments, 0, newArgs, 0, argLength);
                }
                newArgs[i] = environment().computeBoxingType(arguments[i]);
            }
        }
        if (newArgs != null)
            arguments = newArgs;
        method = ParameterizedGenericMethodBinding.computeCompatibleMethod(method, arguments, this,
                invocationSite);
        if (method == null)
            return null; // incompatible
        if (!method.isValidBinding())
            return method; // bound check issue is taking precedence
    } else if (genericTypeArguments != null && compilerOptions().complianceLevel < ClassFileConstants.JDK1_7) {
        if (method instanceof ParameterizedGenericMethodBinding) {
            if (!((ParameterizedGenericMethodBinding) method).wasInferred)
                // attempt to invoke generic method of raw type with type hints <String>foo()
                return new ProblemMethodBinding(method, method.selector, genericTypeArguments,
                        ProblemReasons.TypeArgumentsForRawGenericMethod);
        } else if (!method.isOverriding() || !isOverriddenMethodGeneric(method)) {
            return new ProblemMethodBinding(method, method.selector, genericTypeArguments,
                    ProblemReasons.TypeParameterArityMismatch);
        }
    }

    if (parameterCompatibilityLevel(method, arguments) > NOT_COMPATIBLE) {
        if ((method.tagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
            // generate polymorphic method
            return this.environment().createPolymorphicMethod(method, arguments);
        }
        return method;
    }
    // if method is generic and type arguments have been supplied, only then answer a problem 
    // of ParameterizedMethodTypeMismatch, else a non-generic method was invoked using type arguments
    // in which case this problem category will be bogus
    if (genericTypeArguments != null && typeVariables != Binding.NO_TYPE_VARIABLES)
        return new ProblemMethodBinding(method, method.selector, arguments,
                ProblemReasons.ParameterizedMethodTypeMismatch);
    return null; // incompatible
}