remove all non-function statements after completion statements in blocks
This commit is contained in:
parent
7b359f46fd
commit
43c0a0e65f
@ -19,7 +19,7 @@ function toStatements(node) {
|
||||
|
||||
export var metadata = {
|
||||
optional: true,
|
||||
group: "builtin-setup"
|
||||
group: "builtin-basic"
|
||||
};
|
||||
|
||||
export function ReferencedIdentifier(node, parent, scope) {
|
||||
@ -76,6 +76,25 @@ export function ConditionalExpression(node, parent, scope) {
|
||||
}
|
||||
}
|
||||
|
||||
export function BlockStatement(node) {
|
||||
var paths = this.get("body");
|
||||
|
||||
var purge = false;
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
let path = paths[i];
|
||||
|
||||
if (!purge && path.isCompletionStatement()) {
|
||||
purge = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (purge && !path.isFunctionDeclaration()) {
|
||||
path.dangerouslyRemove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export var IfStatement = {
|
||||
exit(node) {
|
||||
var consequent = node.consequent;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user