chore: remove unreadable blocks and use comments instead.

This commit is contained in:
Artem Kobzar
2022-03-14 21:01:51 +01:00
committed by teamcity
parent fba4ac12b7
commit c6136619d2
8 changed files with 695 additions and 13 deletions
@@ -1275,7 +1275,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
sourceLocationConsumer.pushSourceInfo(null);
boolean needBraces = !x.isGlobalBlock();
boolean needBraces = !x.isGlobalBlock() && !x.isVirtualBlock();
if (needBraces) {
blockOpen();
}
@@ -47,6 +47,8 @@ public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
return false;
}
public boolean isVirtualBlock() { return false; }
@Override
public void accept(JsVisitor v) {
v.visitBlock(this);
@@ -0,0 +1,23 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package org.jetbrains.kotlin.js.backend.ast;
import org.jetbrains.kotlin.js.util.AstUtil;
/**
* Represents a JavaScript block in the global scope.
*/
class JsVirtualBlock(statements: List<JsStatement> = emptyList()) : JsBlock(statements) {
override fun isVirtualBlock(): Boolean {
return true
}
override fun deepCopy(): JsVirtualBlock {
val globalBlockCopy = JsVirtualBlock()
val statementscopy = AstUtil.deepCopy(statements);
globalBlockCopy.statements.addAll(statementscopy);
return globalBlockCopy.withMetadataFrom(this);
}
}