Example usage for org.eclipse.jdt.internal.compiler.lookup Binding NO_ANNOTATIONS

List of usage examples for org.eclipse.jdt.internal.compiler.lookup Binding NO_ANNOTATIONS

Introduction

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

Prototype

AnnotationBinding[] NO_ANNOTATIONS

To view the source code for org.eclipse.jdt.internal.compiler.lookup Binding NO_ANNOTATIONS.

Click Source Link

Usage

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

License:Open Source License

AnnotationBinding[] retrieveAnnotations(Binding binding) {
    AnnotationHolder holder = retrieveAnnotationHolder(binding, true);
    return holder == null ? Binding.NO_ANNOTATIONS : holder.getAnnotations();
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.DeclaredLifting.java

License:Open Source License

private static IfStatement genNewIf(BlockScope scope, AstGenerator gen, ReferenceBinding boundDescendant,
        LookupEnvironment environment) {
    TypeBinding boundBase = boundDescendant.baseclass();
    if (RoleTypeBinding.isRoleWithExplicitAnchor(boundBase)) {
        if (boundBase.isParameterizedType()) {
            // tricky case: need to discard type parameters, but retain/recreate the role type wrapping:
            RoleTypeBinding baseRole = (RoleTypeBinding) boundBase;
            boundBase = environment.createParameterizedType(baseRole._declaredRoleType, null, // erase type parameters
                    baseRole._teamAnchor, // but retain anchor
                    -1, // valueParamPosition
                    baseRole.enclosingType(), Binding.NO_ANNOTATIONS);
        }//w w  w  . jav a2 s .c  o m
        // only RTB but not parameterized: leave unchanged.
    } else {
        boundBase = boundBase.erasure();
    }
    return gen.ifStatement(
            gen.instanceOfExpression(gen.singleNameReference(IOTConstants.BASE), gen.typeReference(boundBase)),
            gen.returnStatement(Lifting.liftCall(
                    scope, gen.thisReference(), gen.castExpression(gen.singleNameReference(IOTConstants.BASE),
                            gen.typeReference(boundBase), CastExpression.DO_WRAP),
                    boundBase, boundDescendant, false/*needLowering*/)),
            null);
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.mappings.CallinImplementor.java

License:Open Source License

private Statement createLiftedRoleVar(CallinMappingDeclaration callinBindingDeclaration, RoleModel roleModel,
        ReferenceBinding baseTypeBinding, char[] otBaseArg, AstGenerator gen) {
    MessageSend liftCall = Lifting.liftCall(callinBindingDeclaration.scope, ThisReference.implicitThis(),
            gen.baseNameReference(otBaseArg), baseTypeBinding, roleModel.getBinding(),
            callinBindingDeclaration.isReplaceCallin()/* needLowering*/);

    ReferenceBinding roleVarType = roleModel.getInterfacePartBinding();
    // does lifting use type parameters? If so, use the same types as type arguments for the role variable
    MethodBinding[] liftMethod = roleVarType.enclosingType().getMethods(liftCall.selector);
    if (liftMethod != null && liftMethod.length > 0) {
        TypeBinding[] typeArguments = liftMethod[0].typeVariables();
        if (typeArguments != Binding.NO_TYPE_VARIABLES)
            try {
                // FIXME: pass null annotations, once JDT supports those on a type declaration.
                roleVarType = Config.getLookupEnvironment().createParameterizedType(roleVarType, typeArguments,
                        null, -1, roleModel.getBinding().enclosingType(), Binding.NO_ANNOTATIONS);
            } catch (NotConfiguredException e) {
                e.logWarning("Cannot lookup parameterized type"); //$NON-NLS-1$
            }//from  www.  j av  a  2s.c o m
    }
    return gen.localVariable(ROLE_VAR_NAME, roleVarType, liftCall);
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstConverter.java

License:Open Source License

public static FieldDeclaration createField(FieldBinding fieldBinding, TypeDeclaration roleDeclaration,
        AstGenerator gen) {//  w  w w.  j  a v a 2  s .c  o  m

    if (fieldBinding == null)
        return null;

    FieldDeclaration fieldDeclaration = new FieldDeclaration();
    fieldDeclaration.type = gen.typeReference(fieldBinding.type);

    fieldDeclaration.modifiers = (fieldBinding.modifiers & ~ExtraCompilerModifiers.AccBlankFinal); // this modifier is not used on fieldDecl (AST), overlaps with AccReadOnly
    fieldDeclaration.name = fieldBinding.name;
    if (fieldBinding.copyInheritanceSrc != null)
        fieldDeclaration.copyInheritanceSrc = fieldBinding.copyInheritanceSrc;
    else
        fieldDeclaration.copyInheritanceSrc = fieldBinding;

    AnnotationBinding[] annotBindings = fieldBinding.getAnnotations();
    if (annotBindings != Binding.NO_ANNOTATIONS) {
        ProblemReporter pr = fieldBinding.isStatic() ? roleDeclaration.staticInitializerScope.problemReporter()
                : roleDeclaration.initializerScope.problemReporter();
        Annotation[] annotDecls = new Annotation[annotBindings.length];
        boolean hasAnnotationError = false;
        for (int i = 0; i < annotBindings.length; i++) {
            AnnotationBinding binding = annotBindings[i];
            ElementValuePair[] elementValuePairs = binding.getElementValuePairs();
            char[][] annotTypeName = binding.getAnnotationType().compoundName;
            if (elementValuePairs == Binding.NO_ELEMENT_VALUE_PAIRS) {
                annotDecls[i] = gen.markerAnnotation(annotTypeName);
            } else {
                int numPairs = elementValuePairs.length;
                char[][] names = new char[numPairs][];
                Expression[] values = new Expression[numPairs];
                for (int j = 0; j < names.length; j++) {
                    names[j] = elementValuePairs[j].getName();
                    Object elementValue = elementValuePairs[j].getValue();
                    values[j] = annotationValues(elementValue, gen, pr);
                }
                if (values.length == 0 || values[0] == null) {
                    pr.unexpectedAnnotationStructure(annotTypeName, fieldBinding.name, gen.sourceStart,
                            gen.sourceEnd);
                    hasAnnotationError = true;
                } else if (numPairs == 1 && CharOperation.equals(names[0], TypeConstants.VALUE)) {
                    annotDecls[i] = gen.singleMemberAnnotation(annotTypeName, values[0]);
                } else {
                    annotDecls[i] = gen.normalAnnotation(annotTypeName, names, values);
                }
            }
        }
        if (!hasAnnotationError)
            fieldDeclaration.annotations = annotDecls;
    }

    //field initializations are copied using a RoleInitializationMethod
    return fieldDeclaration;
}