mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
added advanced substitution methods
This commit is contained in:
parent
8eb4423692
commit
d786dd2aaa
@ -2118,6 +2118,10 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
||||
@Override
|
||||
public void visitMethodDef(JCMethodDecl methodDecl) {
|
||||
|
||||
if (getAdapter().substituteExecutable(methodDecl.sym)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.hasAnnotationType(methodDecl.sym, JSweetConfig.ANNOTATION_ERASED)) {
|
||||
// erased elements are ignored
|
||||
return;
|
||||
@ -3140,6 +3144,11 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
||||
*/
|
||||
@Override
|
||||
public void visitVarDef(JCVariableDecl varDecl) {
|
||||
|
||||
if (getAdapter().substituteVariable(varDecl.sym)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.hasAnnotationType(varDecl.sym, JSweetConfig.ANNOTATION_ERASED)) {
|
||||
// erased elements are ignored
|
||||
return;
|
||||
|
||||
@ -871,6 +871,28 @@ public class PrinterAdapter {
|
||||
return parentAdapter == null ? false : parentAdapter.substituteType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a given executable declaration.
|
||||
*
|
||||
* @param executable
|
||||
* the executable being printed
|
||||
* @return true if substituted
|
||||
*/
|
||||
public boolean substituteExecutable(ExecutableElement executable) {
|
||||
return parentAdapter == null ? false : parentAdapter.substituteExecutable(executable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a given variable declaration.
|
||||
*
|
||||
* @param variable
|
||||
* the variable being printed
|
||||
* @return true if substituted
|
||||
*/
|
||||
public boolean substituteVariable(VariableElement variable) {
|
||||
return parentAdapter == null ? false : parentAdapter.substituteVariable(variable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes the value of a <em>field assignment</em> expression.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user