Beispiel #1
0
  /** Returns a description for a member suitable for reporting errors to the users. */
  public static String getReadableDescription(JMember member) {
    if (member instanceof JField) {
      return String.format(
          "%s %s.%s",
          getReadableDescription(member.getType()),
          getReadableDescription(member.getEnclosingType()),
          member.getName());
    }

    JMethod method = (JMethod) member;
    String printableDescription = "";
    if (!method.isConstructor()) {
      printableDescription += getReadableDescription(method.getType()) + " ";
    }
    printableDescription +=
        String.format(
            "%s.%s(%s)",
            getReadableDescription(method.getEnclosingType()),
            method.getName(),
            Joiner.on(", ")
                .join(
                    Iterables.transform(
                        method.getOriginalParamTypes(),
                        new Function<JType, String>() {
                          @Override
                          public String apply(JType type) {
                            return getReadableDescription(type);
                          }
                        })));
    return printableDescription;
  }
Beispiel #2
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);
  }
Beispiel #3
0
  private static void setJsInteropProperties(JMember member, Annotation... annotations) {
    String namespace = maybeGetJsNamespace(annotations);
    String exportName = maybeGetJsExportName(annotations, computeExportName(member));
    member.setExportInfo(namespace, exportName);

    /* Apply class wide JsInterop annotations */

    boolean ignore = JdtUtil.getAnnotation(annotations, JSNOEXPORT_CLASS) != null;
    if (ignore || !member.isPublic()) {
      return;
    }

    JDeclaredType enclosingType = member.getEnclosingType();

    if (enclosingType.isJsType() && member.needsVtable()) {
      member.setJsMemberName(member.getName());
    }

    if (enclosingType.isClassWideExport() && !member.needsVtable() && exportName == null) {
      member.setExportInfo(namespace, computeExportName(member));
    }
  }
Beispiel #4
0
 private static String computeName(JMember member) {
   return member instanceof JConstructor ? "" : member.getName();
 }
Beispiel #5
0
 private static boolean isNativeConstructor(JMember member) {
   return member instanceof JConstructor && member.isJsNative();
 }
Beispiel #6
0
 public static String getIndexedName(JMember member) {
   return member.getEnclosingType().getShortName() + '.' + member.getName();
 }