feat: refactoring project
This commit is contained in:
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
@@ -33,7 +33,7 @@ function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
@@ -50,7 +50,7 @@ function IfStatement(node) {
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
@@ -60,7 +60,7 @@ function IfStatement(node) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate, node);
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
@@ -77,20 +77,20 @@ function ForStatement(node) {
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = this.enterForStatementInit(true);
|
||||
const exit = this.enterForStatementInit();
|
||||
this.tokenContext |= _index.TokenContext.forHead;
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
exit();
|
||||
}
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
}
|
||||
this.tokenChar(59);
|
||||
this.token(";", false, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
@@ -99,7 +99,7 @@ function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -114,15 +114,15 @@ function ForXStatement(node) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = isForOf ? null : this.enterForStatementInit(true);
|
||||
const exit = isForOf ? null : this.enterForStatementInit();
|
||||
this.tokenContext |= isForOf ? _index.TokenContext.forOfHead : _index.TokenContext.forInHead;
|
||||
this.print(node.left, node);
|
||||
this.print(node.left);
|
||||
exit == null || exit();
|
||||
}
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -131,59 +131,59 @@ const ForOfStatement = exports.ForOfStatement = ForXStatement;
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node, parent, isLabel) {
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node, parent, isLabel);
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label, node);
|
||||
this.print(node.label);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block, node);
|
||||
this.print(node.block);
|
||||
this.space();
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0], node);
|
||||
this.print(node.handlers[0]);
|
||||
} else {
|
||||
this.print(node.handler, node);
|
||||
this.print(node.handler);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer, node);
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
@@ -191,22 +191,22 @@ function CatchClause(node) {
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param, node);
|
||||
this.print(node.param.typeAnnotation, node);
|
||||
this.print(node.param);
|
||||
this.print(node.param.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant, node);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, node, {
|
||||
this.printSequence(node.cases, {
|
||||
indent: true,
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
@@ -218,7 +218,7 @@ function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
@@ -226,7 +226,7 @@ function SwitchCase(node) {
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
this.printSequence(node.consequent, {
|
||||
indent: true
|
||||
});
|
||||
}
|
||||
@@ -259,9 +259,9 @@ function VariableDeclaration(node, parent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, node, {
|
||||
separator: hasInits ? function () {
|
||||
this.tokenChar(44);
|
||||
this.printList(node.declarations, {
|
||||
separator: hasInits ? function (occurrenceCount) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
this.newline();
|
||||
} : undefined,
|
||||
indent: node.declarations.length > 1 ? true : false
|
||||
@@ -276,14 +276,14 @@ function VariableDeclaration(node, parent) {
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.print(node.id.typeAnnotation);
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user