示例#1
0
  private static void setJsInteropPropertiesNew(
      JMember member, Annotation[] annotations, AnnotationBinding memberAnnotation) {
    if (getInteropAnnotation(annotations, "JsIgnore") != null) {
      return;
    }

    boolean isPublicMemberForJsType = member.getEnclosingType().isJsType() && member.isPublic();
    if (!isPublicMemberForJsType && !isNativeConstructor(member) && memberAnnotation == null) {
      return;
    }

    String namespace = JdtUtil.getAnnotationParameterString(memberAnnotation, "namespace");
    String name = JdtUtil.getAnnotationParameterString(memberAnnotation, "name");
    member.setJsMemberInfo(namespace, name == null ? computeName(member) : name, true);
  }
示例#2
0
 public static void maybeSetJsInteropProperties(JDeclaredType type, Annotation... annotations) {
   AnnotationBinding jsType = JdtUtil.getAnnotation(annotations, JSTYPE_CLASS);
   String namespace = maybeGetJsNamespace(annotations);
   String exportName = maybeGetJsExportName(annotations, "");
   String jsPrototype = JdtUtil.getAnnotationParameterString(jsType, "prototype");
   boolean isJsNative = jsPrototype != null;
   if (isJsNative) {
     int indexOf = jsPrototype.lastIndexOf(".");
     namespace = indexOf == -1 ? "" : jsPrototype.substring(0, indexOf);
     exportName = jsPrototype.substring(indexOf + 1);
   }
   boolean isJsType = jsType != null;
   boolean isClassWideExport = exportName != null;
   boolean isJsFunction = JdtUtil.getAnnotation(annotations, JSFUNCTION_CLASS) != null;
   boolean canBeImplementedExternally =
       (type instanceof JInterfaceType && (isJsType || isJsFunction))
           || (type instanceof JClassType && isJsNative);
   type.setJsTypeInfo(
       isJsType,
       isJsNative,
       isJsFunction,
       namespace,
       exportName,
       isClassWideExport,
       canBeImplementedExternally);
 }
示例#3
0
 private static String maybeGetJsExportName(Annotation[] annotations, String calculatedName) {
   AnnotationBinding jsExport = JdtUtil.getAnnotation(annotations, JSEXPORT_CLASS);
   if (jsExport == null) {
     return null;
   }
   String value = JdtUtil.getAnnotationParameterString(jsExport, "value");
   return Strings.isNullOrEmpty(value) ? calculatedName : value;
 }
示例#4
0
  public static void maybeSetJsInteropPropertiesNew(JDeclaredType type, Annotation[] annotations) {
    AnnotationBinding jsType = getInteropAnnotation(annotations, "JsType");
    String namespace = JdtUtil.getAnnotationParameterString(jsType, "namespace");
    String name = JdtUtil.getAnnotationParameterString(jsType, "name");
    boolean isJsNative = JdtUtil.getAnnotationParameterBoolean(jsType, "isNative", false);

    AnnotationBinding jsPackage = getInteropAnnotation(annotations, "JsPackage");
    String packageNamespace = JdtUtil.getAnnotationParameterString(jsPackage, "namespace");
    if (packageNamespace != null) {
      namespace = packageNamespace;
    }

    boolean isJsType = jsType != null;
    boolean isJsFunction = getInteropAnnotation(annotations, "JsFunction") != null;
    boolean canBeImplementedExternally = isJsNative || isJsFunction;
    type.setJsTypeInfo(
        isJsType, isJsNative, isJsFunction, namespace, name, isJsType, canBeImplementedExternally);
  }
示例#5
0
  public static void maybeSetJsInteropProperties(JDeclaredType type, Annotation... annotations) {
    AnnotationBinding jsType = JdtUtil.getAnnotation(annotations, JSTYPE_CLASS);
    String jsPrototype = JdtUtil.getAnnotationParameterString(jsType, "prototype");
    type.setJsTypeInfo(jsType != null, jsPrototype);

    String namespace = maybeGetJsNamespace(annotations);
    String exportName = maybeGetJsExportName(annotations, "");
    type.setExportInfo(namespace, exportName);

    type.setJsFunctionInfo(JdtUtil.getAnnotation(annotations, JSFUNCTION_CLASS) != null);
  }
示例#6
0
 private static String maybeGetJsNamespace(Annotation[] annotations) {
   AnnotationBinding jsNamespace = JdtUtil.getAnnotation(annotations, JSNAMESPACE_CLASS);
   return JdtUtil.getAnnotationParameterString(jsNamespace, "value");
 }