move the overload method name generation to the adapter layer (for custom naming)

This commit is contained in:
Renaud Pawlak 2021-01-10 22:57:19 +01:00
parent 850104f6b2
commit 6763804c19
2 changed files with 3 additions and 16 deletions

View File

@ -3209,20 +3209,7 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
}
private String getOverloadMethodName(MethodSymbol method) {
//return getAdapter().getOverloadMethodName(method);
if (method.isConstructor()) {
return "constructor";
}
StringBuilder sb = new StringBuilder(method.getSimpleName().toString());
sb.append("$");
for (VarSymbol p : method.getParameters()) {
sb.append(context.types.erasure(p.type).toString().replace('.', '_').replace("[]", "_A"));
sb.append("$");
}
if (!method.getParameters().isEmpty()) {
sb.deleteCharAt(sb.length() - 1);
}
return sb.toString();
return getAdapter().getOverloadName(method);
}
private void checkType(TypeSymbol type) {

View File

@ -1285,14 +1285,14 @@ public class PrinterAdapter {
* @param exectuable the executable to get the overload name
* @return the overload name
*/
public String getOverloadMethodName(ExecutableElement executable) {
public String getOverloadName(ExecutableElement executable) {
if (executable.getKind() == ElementKind.CONSTRUCTOR) {
return "constructor";
}
StringBuilder sb = new StringBuilder(executable.getSimpleName().toString());
sb.append("$");
for (VariableElement p : executable.getParameters()) {
sb.append(types.erasure(p.asType()).toString().replace('.', '_').replace("[]", "_A"));
sb.append(types().erasure(p.asType()).toString().replace('.', '_').replace("[]", "_A"));
sb.append("$");
}
if (!executable.getParameters().isEmpty()) {