fix: block statements rendering.
This commit is contained in:
@@ -458,11 +458,13 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
|
|
||||||
popSourceInfo();
|
popSourceInfo();
|
||||||
|
|
||||||
nestedPush(x.getBody());
|
JsStatement body = materialize(x.getBody());
|
||||||
|
|
||||||
|
nestedPush(body);
|
||||||
sourceLocationConsumer.pushSourceInfo(null);
|
sourceLocationConsumer.pushSourceInfo(null);
|
||||||
accept(x.getBody());
|
accept(body);
|
||||||
sourceLocationConsumer.popSourceInfo();
|
sourceLocationConsumer.popSourceInfo();
|
||||||
nestedPop(x.getBody());
|
nestedPop(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -470,10 +472,13 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
sourceLocationConsumer.pushSourceInfo(null);
|
sourceLocationConsumer.pushSourceInfo(null);
|
||||||
|
|
||||||
p.print(CHARS_DO);
|
p.print(CHARS_DO);
|
||||||
nestedPush(x.getBody());
|
|
||||||
accept(x.getBody());
|
JsStatement body = materialize(x.getBody());
|
||||||
|
|
||||||
|
nestedPush(body);
|
||||||
|
accept(body);
|
||||||
sourceLocationConsumer.popSourceInfo();
|
sourceLocationConsumer.popSourceInfo();
|
||||||
nestedPop(x.getBody());
|
nestedPop(body);
|
||||||
|
|
||||||
pushSourceInfo(x.getCondition().getSource());
|
pushSourceInfo(x.getCondition().getSource());
|
||||||
if (needSemi) {
|
if (needSemi) {
|
||||||
@@ -557,13 +562,15 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
|
|
||||||
popSourceInfo();
|
popSourceInfo();
|
||||||
|
|
||||||
nestedPush(x.getBody());
|
JsStatement body = materialize(x.getBody());
|
||||||
if (x.getBody() != null) {
|
|
||||||
|
nestedPush(body);
|
||||||
|
if (body != null) {
|
||||||
sourceLocationConsumer.pushSourceInfo(null);
|
sourceLocationConsumer.pushSourceInfo(null);
|
||||||
accept(x.getBody());
|
accept(body);
|
||||||
sourceLocationConsumer.popSourceInfo();
|
sourceLocationConsumer.popSourceInfo();
|
||||||
}
|
}
|
||||||
nestedPop(x.getBody());
|
nestedPop(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -601,11 +608,12 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
|
|
||||||
popSourceInfo();
|
popSourceInfo();
|
||||||
|
|
||||||
nestedPush(x.getBody());
|
JsStatement body = materialize(x.getBody());
|
||||||
|
nestedPush(body);
|
||||||
sourceLocationConsumer.pushSourceInfo(null);
|
sourceLocationConsumer.pushSourceInfo(null);
|
||||||
accept(x.getBody());
|
accept(body);
|
||||||
sourceLocationConsumer.popSourceInfo();
|
sourceLocationConsumer.popSourceInfo();
|
||||||
nestedPop(x.getBody());
|
nestedPop(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -715,7 +723,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceLocationConsumer.pushSourceInfo(null);
|
sourceLocationConsumer.pushSourceInfo(null);
|
||||||
accept(thenStmt);
|
accept(materialize(thenStmt));
|
||||||
sourceLocationConsumer.popSourceInfo();
|
sourceLocationConsumer.popSourceInfo();
|
||||||
|
|
||||||
nestedPop(thenStmt);
|
nestedPop(thenStmt);
|
||||||
@@ -757,6 +765,12 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static JsStatement materialize(@NotNull JsStatement statement) {
|
||||||
|
return statement instanceof JsCompositeBlock && ((JsCompositeBlock) statement).getStatements().size() > 1
|
||||||
|
? new JsBlock(statement)
|
||||||
|
: statement;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitInvocation(@NotNull JsInvocation invocation) {
|
public void visitInvocation(@NotNull JsInvocation invocation) {
|
||||||
pushSourceInfo(invocation.getSource());
|
pushSourceInfo(invocation.getSource());
|
||||||
|
|||||||
Reference in New Issue
Block a user