Ejemplo n.º 1
0
 public static String constructManglingSignature(JMethod x, String partialSignature) {
   StringBuilder sb = new StringBuilder(partialSignature);
   sb.append("__");
   for (int i = 0; i < x.getOriginalParamTypes().size(); ++i) {
     JType type = x.getOriginalParamTypes().get(i);
     sb.append(type.getJavahSignatureName());
   }
   sb.append(x.getOriginalReturnType().getJavahSignatureName());
   return sb.toString();
 }
Ejemplo n.º 2
0
 public static String computeSignature(
     String name, List<JType> params, JType returnType, boolean isCtor) {
   StringBuilder sb = new StringBuilder(name);
   sb.append('(');
   for (JType type : params) {
     sb.append(type.getJsniSignatureName());
   }
   sb.append(')');
   if (!isCtor) {
     sb.append(returnType.getJsniSignatureName());
   } else {
     sb.append(" <init>");
   }
   return sb.toString();
 }
Ejemplo n.º 3
0
  /**
   * Java8 Method References such as String::equalsIgnoreCase should produce inner class names that
   * are a function of the samInterface (e.g. Runnable), the method being referred to, and the
   * qualifying disposition (this::foo vs Class::foo if foo is an instance method)
   */
  public static String classNameForMethodReference(
      JType cuType,
      JInterfaceType functionalInterface,
      JMethod referredMethod,
      boolean hasReceiver) {
    String prefix =
        classNamePrefixForMethodReference(
            cuType.getPackageName(),
            cuType.getName(),
            functionalInterface.getName(),
            referredMethod.getEnclosingType().getName(),
            referredMethod.getName(),
            hasReceiver);

    return StringInterner.get().intern(constructManglingSignature(referredMethod, prefix));
  }
Ejemplo n.º 4
0
 /** Returns a description for a type suitable for reporting errors to the users. */
 public static String getReadableDescription(JType type) {
   if (type instanceof JArrayType) {
     JArrayType arrayType = (JArrayType) type;
     return getReadableDescription(arrayType.getLeafType())
         + Strings.repeat("[]", arrayType.getDims());
   }
   return Joiner.on(".").join(type.getCompoundName());
 }