Examples of AnnotationBinding


Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

    int se8count = 0;
    long se8nullBits = 0;
    Annotation se8NullAnnotation = null;
    int firstSE8 = -1, lastSE8 = 0;
    for (int i = 0, length = annotations.length; i < length; i++) {
      AnnotationBinding annotation = annotations[i].getCompilerAnnotation();
      if (annotation == null) continue;
      final ReferenceBinding annotationType = annotation.getAnnotationType();
      long metaTagBits = annotationType.getAnnotationTagBits();
      if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
        if (firstSE8 == -1) firstSE8 = i;
        lastSE8 = i;
        if (se8Annotations == null) {
          se8Annotations = new AnnotationBinding[] { annotation };
          se8count = 1;
        } else {
          System.arraycopy(se8Annotations, 0, se8Annotations = new AnnotationBinding[se8count + 1], 0, se8count);
          se8Annotations[se8count++] = annotation;
        }
        if (annotationType.id == TypeIds.T_ConfiguredAnnotationNonNull) {
          se8nullBits = TagBits.AnnotationNonNull;
          se8NullAnnotation = annotations[i];
        } else if (annotationType.id == TypeIds.T_ConfiguredAnnotationNullable) {
          se8nullBits = TagBits.AnnotationNullable;
          se8NullAnnotation = annotations[i];
        }
      }
    }
    if (se8Annotations != null) {
      if (!isLegalLocation) {
        scope.problemReporter().misplacedTypeAnnotations(annotations[firstSE8], annotations[lastSE8]);
        return;
      }
      switch (recipient.kind()) {
        case Binding.LOCAL:
          LocalVariableBinding local = (LocalVariableBinding) recipient;
          TypeReference typeRef = local.declaration.type;
          if (Annotation.isTypeUseCompatible(typeRef, scope)) { // discard hybrid annotations on name qualified types.
            local.declaration.bits |= HasTypeAnnotations;
            typeRef.bits |= HasTypeAnnotations;
            local.type = mergeAnnotationsIntoType(scope, se8Annotations, se8nullBits, se8NullAnnotation, typeRef, local.type);
          }
          break;
        case Binding.FIELD:
          FieldBinding field = (FieldBinding) recipient;
          SourceTypeBinding sourceType = (SourceTypeBinding) field.declaringClass;
          FieldDeclaration fieldDeclaration = sourceType.scope.referenceContext.declarationOf(field);
          if (Annotation.isTypeUseCompatible(fieldDeclaration.type, scope)) { // discard hybrid annotations on name qualified types.
            fieldDeclaration.bits |= HasTypeAnnotations;
            fieldDeclaration.type.bits |= HasTypeAnnotations;
            field.type = mergeAnnotationsIntoType(scope, se8Annotations, se8nullBits, se8NullAnnotation, fieldDeclaration.type, field.type);
          }
          break;
        case Binding.METHOD:
          MethodBinding method = (MethodBinding) recipient;
          if (!method.isConstructor()) {
            sourceType = (SourceTypeBinding) method.declaringClass;
            MethodDeclaration methodDecl = (MethodDeclaration) sourceType.scope.referenceContext.declarationOf(method);
            if (Annotation.isTypeUseCompatible(methodDecl.returnType, scope)) {
              methodDecl.bits |= HasTypeAnnotations;
              methodDecl.returnType.bits |= HasTypeAnnotations;
              method.returnType = mergeAnnotationsIntoType(scope, se8Annotations, se8nullBits, se8NullAnnotation, methodDecl.returnType, method.returnType);
            }
          }
          break;
      }
      AnnotationBinding [] recipientAnnotations = recipient.getAnnotations();
      int length = recipientAnnotations == null ? 0 : recipientAnnotations.length;
      int newLength = 0;
      for (int i = 0; i < length; i++) {
        final AnnotationBinding recipientAnnotation = recipientAnnotations[i];
        if (recipientAnnotation == null)
          continue;
        long annotationTargetMask = recipientAnnotation.getAnnotationType().getAnnotationTagBits() & TagBits.AnnotationTargetMASK;
        if (annotationTargetMask == 0 || (annotationTargetMask & recipientTargetMask) != 0)
          recipientAnnotations[newLength++] = recipientAnnotation;
      }
      if (newLength != length) {
        System.arraycopy(recipientAnnotations, 0, recipientAnnotations = new AnnotationBinding[newLength]0, newLength);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

    if (!(typeBinding instanceof ReferenceBinding) || !(typeBinding instanceof SourceTypeBinding)) {
      return false;
    }

    AnnotationBinding jsInterface = JdtUtil.getAnnotation(typeBinding, JsInteropUtil.JSTYPE_CLASS);
    return jsInterface != null;
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

    }

    private void checkJsType(TypeDeclaration type, TypeBinding typeBinding) {
      ReferenceBinding binding = (ReferenceBinding) typeBinding;
      if (binding.isClass()) {
        AnnotationBinding jsinterfaceAnn = JdtUtil.getAnnotation(typeBinding,
          JsInteropUtil.JSTYPE_CLASS);
        String jsPrototype = JdtUtil.getAnnotationParameterString(jsinterfaceAnn, "prototype");
        if (jsPrototype != null && !"".equals(jsPrototype)) {
          errorOn(type, ERR_JS_TYPE_WITH_PROTOTYPE_SET_NOT_ALLOWED_ON_CLASS_TYPES);
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

        checkJsExport(mb, false);
      }
    }

    private void checkJsExport(MethodBinding mb, boolean allowed) {
      AnnotationBinding jsExport = JdtUtil.getAnnotation(mb, JsInteropUtil.JSEXPORT_CLASS);
      if (jsExport != null && allowed) {
        if (!mb.isConstructor() && !mb.isStatic()) {
          errorOn(mb.sourceMethod(), ERR_JSEXPORT_ONLY_CTORS_AND_STATIC_METHODS);
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

        errorOn(mb.sourceMethod(), ERR_JSEXPORT_USED_ON_JSTYPE_INTERFACE);
      }
    }

    private void checkJsProperty(MethodBinding mb, boolean allowed) {
      AnnotationBinding jsProperty = JdtUtil.getAnnotation(mb, JsInteropUtil.JSPROPERTY_CLASS);
      if (jsProperty != null) {
        if (!allowed) {
          errorOn(mb.sourceMethod(), ERR_JSPROPERTY_ONLY_ON_INTERFACES);
          return;
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

      for (MethodBinding mb : type.binding.methods()) {
        checkJsExport(mb, true);
        checkJsProperty(mb, false);
      }

      AnnotationBinding jsinterfaceAnn = JdtUtil.getAnnotation(jsInterface,
          JsInteropUtil.JSTYPE_CLASS);
      String jsPrototype = JdtUtil.getAnnotationParameterString(jsinterfaceAnn, "prototype");
      boolean isNative = JdtUtil.getAnnotationParameterBoolean(jsinterfaceAnn, "isNative");
      if (!Strings.isNullOrEmpty(jsPrototype)) {
        checkClassExtendsMagicPrototype(type, jsInterface, !isNative, isNative);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

  }

  static AnnotationBinding getAnnotation(Annotation[] annotations, String nameToFind) {
    if (annotations != null) {
      for (Annotation a : annotations) {
        AnnotationBinding annBinding = a.getCompilerAnnotation();
        if (annBinding != null) {
          String annName = CharOperation.toString(annBinding.getAnnotationType().compoundName);
          if (nameToFind.equals(annName)) {
            return annBinding;
          }
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

  public static final String JSTYPEPROTOTYPE_CLASS =
      "com.google.gwt.core.client.js.impl.PrototypeOfJsType";

  public static String maybeGetJsNamespace(TypeDeclaration x) {
    if (x.annotations != null) {
      AnnotationBinding jsNamespace = JdtUtil.getAnnotation(x.binding, JSNAMESPACE_CLASS);
      if (jsNamespace != null) {
       return JdtUtil.getAnnotationParameterString(jsNamespace, "value");
      }
    }
    return null;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

    return null;
  }

  public static void maybeSetExportedField(FieldDeclaration x, JField field) {
    if (x.annotations != null) {
      AnnotationBinding jsExport = JdtUtil.getAnnotation(x.binding, JSEXPORT_CLASS);
      if (jsExport != null) {
        field.setExportName(JdtUtil.getAnnotationParameterString(jsExport, "value"));
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding

  }

  public static void maybeSetJsinteropMethodProperties(AbstractMethodDeclaration x,
      JMethod method) {
    if (x.annotations != null) {
      AnnotationBinding jsExport = JdtUtil.getAnnotation(x.binding, JSEXPORT_CLASS);
      AnnotationBinding jsProperty = JdtUtil.getAnnotation(x.binding, JSPROPERTY_CLASS);
      if (jsExport != null) {
        method.setExportName(JdtUtil.getAnnotationParameterString(jsExport, "value"));
      }
      if (jsProperty != null) {
        method.setJsProperty(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.