avancement planning

This commit is contained in:
2026-05-26 11:58:39 +02:00
parent 619a2b240a
commit 150b97cd2e
4892 changed files with 99214 additions and 429382 deletions
+58 -38
View File
@@ -8,7 +8,8 @@ exports.CatchClause = CatchClause;
exports.ContinueStatement = ContinueStatement;
exports.DebuggerStatement = DebuggerStatement;
exports.DoWhileStatement = DoWhileStatement;
exports.ForOfStatement = exports.ForInStatement = void 0;
exports.ForInStatement = ForInStatement;
exports.ForOfStatement = ForOfStatement;
exports.ForStatement = ForStatement;
exports.IfStatement = IfStatement;
exports.LabeledStatement = LabeledStatement;
@@ -22,9 +23,9 @@ exports.VariableDeclarator = VariableDeclarator;
exports.WhileStatement = WhileStatement;
exports.WithStatement = WithStatement;
var _t = require("@babel/types");
var _index = require("../node/index.js");
const {
isFor,
isForStatement,
isIfStatement,
isStatement
} = _t;
@@ -34,7 +35,7 @@ function WithStatement(node) {
this.tokenChar(40);
this.print(node.object);
this.tokenChar(41);
this.printBlock(node);
this.printBlock(node.body);
}
function IfStatement(node) {
this.word("if");
@@ -75,23 +76,21 @@ function ForStatement(node) {
this.word("for");
this.space();
this.tokenChar(40);
{
const exit = this.enterForStatementInit();
this.print(node.init);
exit();
}
this.tokenContext |= _index.TokenContext.forInitHead | _index.TokenContext.forInOrInitHeadAccumulate;
this.print(node.init);
this.tokenContext = _index.TokenContext.normal;
this.tokenChar(59);
if (node.test) {
this.space();
this.print(node.test);
}
this.token(";", false, 1);
this.tokenChar(59, 1);
if (node.update) {
this.space();
this.print(node.update);
}
this.tokenChar(41);
this.printBlock(node);
this.printBlock(node.body);
}
function WhileStatement(node) {
this.word("while");
@@ -99,32 +98,41 @@ function WhileStatement(node) {
this.tokenChar(40);
this.print(node.test);
this.tokenChar(41);
this.printBlock(node);
this.printBlock(node.body);
}
function ForXStatement(node) {
function ForInStatement(node) {
this.word("for");
this.space();
const isForOf = node.type === "ForOfStatement";
if (isForOf && node.await) {
this.noIndentInnerCommentsHere();
this.tokenChar(40);
this.tokenContext |= _index.TokenContext.forInHead | _index.TokenContext.forInOrInitHeadAccumulate;
this.print(node.left);
this.tokenContext = _index.TokenContext.normal;
this.space();
this.word("in");
this.space();
this.print(node.right);
this.tokenChar(41);
this.printBlock(node.body);
}
function ForOfStatement(node) {
this.word("for");
this.space();
if (node.await) {
this.word("await");
this.space();
}
this.noIndentInnerCommentsHere();
this.tokenChar(40);
{
const exit = this.enterForXStatementInit(isForOf);
this.print(node.left);
exit == null || exit();
}
this.tokenContext |= _index.TokenContext.forOfHead;
this.print(node.left);
this.space();
this.word(isForOf ? "of" : "in");
this.word("of");
this.space();
this.print(node.right);
this.tokenChar(41);
this.printBlock(node);
this.printBlock(node.body);
}
const ForInStatement = exports.ForInStatement = ForXStatement;
const ForOfStatement = exports.ForOfStatement = ForXStatement;
function DoWhileStatement(node) {
this.word("do");
this.space();
@@ -225,6 +233,10 @@ function DebuggerStatement() {
this.word("debugger");
this.semicolon();
}
function commaSeparatorWithNewline(occurrenceCount) {
this.tokenChar(44, occurrenceCount);
this.newline();
}
function VariableDeclaration(node, parent) {
if (node.declare) {
this.word("declare");
@@ -233,12 +245,15 @@ function VariableDeclaration(node, parent) {
const {
kind
} = node;
if (kind === "await using") {
this.word("await");
this.space();
this.word("using", true);
} else {
this.word(kind, kind === "using");
switch (kind) {
case "await using":
this.word("await");
this.space();
case "using":
this.word("using", true);
break;
default:
this.word(kind);
}
this.space();
let hasInits = false;
@@ -246,18 +261,23 @@ function VariableDeclaration(node, parent) {
for (const declar of node.declarations) {
if (declar.init) {
hasInits = true;
break;
}
}
}
this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? function (occurrenceCount) {
this.token(",", false, occurrenceCount);
this.newline();
} : undefined);
if (isFor(parent)) {
if (isForStatement(parent)) {
if (parent.init === node) return;
} else {
if (parent.left === node) return;
this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? commaSeparatorWithNewline : undefined);
if (parent != null) {
switch (parent.type) {
case "ForStatement":
if (parent.init === node) {
return;
}
break;
case "ForInStatement":
case "ForOfStatement":
if (parent.left === node) {
return;
}
}
}
this.semicolon();