fix: fix syntax error in compiling functions

fix syntax error in DesktopEngine.compileFunction
This commit is contained in:
Frank.R.Wu 2021-11-10 22:07:19 +08:00
parent 24123435be
commit 5ed245459c
3 changed files with 10 additions and 9 deletions

View File

@ -62,11 +62,7 @@ public class ContractNode {
cn.initText(cts);
}
for (FunctionNode fun : functions) {
if (fun.isExport) {
fun.initTextWithoutExport(cts);
} else {
fun.initText(cts);
}
fun.initTextWithCleaning(cts, fun.isExport, fun.isView());
if (fun.isExport || fun.functionName.equals("onCreate")) {
fun.initTextWithRequester();
}

View File

@ -34,10 +34,16 @@ public class Script {
public void initText(CommonTokenStream cts) {
plainText = cts.getText(interval);
}
public void initTextWithoutExport(CommonTokenStream cts) {
plainText = cts.getText(interval).replaceFirst("export", "");
public void initTextWithCleaning(CommonTokenStream cts, boolean isExported, boolean isView) {
String plainText = cts.getText(interval);
if (isExported) {
plainText = plainText.replaceFirst("exported", "");
}
if (isView) {
plainText = plainText.replaceFirst("\\)\\s?view\\s?\\{", "){");
}
this.plainText = plainText;
}
}

View File

@ -57,7 +57,6 @@ public class FunctionReader extends YJSParserBaseVisitor<FunctionNode> {
node.setInterval(
new Interval(ctx.Function().getSourceInterval().a, ctx.getSourceInterval().b));
List<AnnotationContext> annotations = new ArrayList<>();
if (null != ctx.annotations()) {
annotations = ctx.annotations().annotation();