mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
move the overload method name generation to the adapter layer (for custom naming)
This commit is contained in:
parent
850104f6b2
commit
6763804c19
@ -3209,20 +3209,7 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getOverloadMethodName(MethodSymbol method) {
|
private String getOverloadMethodName(MethodSymbol method) {
|
||||||
//return getAdapter().getOverloadMethodName(method);
|
return getAdapter().getOverloadName(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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkType(TypeSymbol type) {
|
private void checkType(TypeSymbol type) {
|
||||||
|
|||||||
@ -1285,14 +1285,14 @@ public class PrinterAdapter {
|
|||||||
* @param exectuable the executable to get the overload name
|
* @param exectuable the executable to get the overload name
|
||||||
* @return the overload name
|
* @return the overload name
|
||||||
*/
|
*/
|
||||||
public String getOverloadMethodName(ExecutableElement executable) {
|
public String getOverloadName(ExecutableElement executable) {
|
||||||
if (executable.getKind() == ElementKind.CONSTRUCTOR) {
|
if (executable.getKind() == ElementKind.CONSTRUCTOR) {
|
||||||
return "constructor";
|
return "constructor";
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder(executable.getSimpleName().toString());
|
StringBuilder sb = new StringBuilder(executable.getSimpleName().toString());
|
||||||
sb.append("$");
|
sb.append("$");
|
||||||
for (VariableElement p : executable.getParameters()) {
|
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("$");
|
sb.append("$");
|
||||||
}
|
}
|
||||||
if (!executable.getParameters().isEmpty()) {
|
if (!executable.getParameters().isEmpty()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user