ability to substitute method overload in adapter

This commit is contained in:
Louis Grignon 2020-07-19 14:35:15 +02:00
parent ec4b74d740
commit 659e715b1b
2 changed files with 16 additions and 0 deletions

View File

@ -2548,6 +2548,10 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
}
private void printCoreOverloadMethod(JCMethodDecl methodDecl, JCClassDecl parent, Overload overload) {
if (getAdapter().substituteOverloadMethodBody(parent.sym, overload)) {
return;
}
boolean wasPrinted = false;
for (int i = 0; i < overload.methods.size(); i++) {
JCMethodDecl method = overload.methods.get(i);

View File

@ -43,6 +43,7 @@ import org.jsweet.transpiler.JSweetContext;
import org.jsweet.transpiler.JSweetOptions;
import org.jsweet.transpiler.JSweetProblem;
import org.jsweet.transpiler.ModuleImportDescriptor;
import org.jsweet.transpiler.OverloadScanner.Overload;
import org.jsweet.transpiler.model.ArrayAccessElement;
import org.jsweet.transpiler.model.AssignmentElement;
import org.jsweet.transpiler.model.AssignmentWithOperatorElement;
@ -762,6 +763,17 @@ public class PrinterAdapter {
public boolean substituteVariableAccess(VariableAccessElement variableAccess) {
return parentAdapter == null ? false : parentAdapter.substituteVariableAccess(variableAccess);
}
/**
* Substitutes overloaded method implementation
*
* @param parentTypeElement parent class
* @param overload overloaded method descriptors
* @return true if substituted
*/
public boolean substituteOverloadMethodBody(TypeElement parentTypeElement, Overload overload) {
return false;
}
/**
* Called if the initializer of a variable is undefined (in order to force a