/** 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; }
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)); } }
private static String computeName(JMember member) { return member instanceof JConstructor ? "" : member.getName(); }
public static String getIndexedName(JMember member) { return member.getEnclosingType().getShortName() + '.' + member.getName(); }