Skip to content

Commit 529389b

Browse files
committed
working
1 parent 7cdd4d7 commit 529389b

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

src/handlers.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ const indent = { type: 'Indent' };
1111
const dedent = { type: 'Dedent' };
1212

1313
/**
14-
* @param {Command[]} children
15-
* @returns {Sequence}
14+
* @returns {Command[]}
1615
*/
17-
function create_sequence(...children) {
18-
return { type: 'Sequence', children };
16+
function create_sequence() {
17+
return [];
1918
}
2019

2120
/**
@@ -31,7 +30,7 @@ function measure(commands, from, to = commands.length) {
3130
if (typeof command === 'string') {
3231
total += command.length;
3332
} else if (Array.isArray(command)) {
34-
total += measure(command, 0, command.length);
33+
total += 2; // TODO `measure(command, 0, command.length)`;
3534
} else if (command.type === 'Chunk') {
3635
total += command.content.length;
3736
}
@@ -287,7 +286,7 @@ const handle_body = (nodes, state) => {
287286
grouped_expression_types.includes(last_statement.type)) &&
288287
last_statement.type !== statement.type)
289288
) {
290-
margin.children.push('\n');
289+
margin.push('\n');
291290
}
292291

293292
let add_newline = false;
@@ -331,11 +330,11 @@ const handle_var_declaration = (node, state) => {
331330

332331
if (multiline) {
333332
state.multiline = true;
334-
if (node.declarations.length > 1) open.children.push(indent);
335-
join.children.push(',', newline);
333+
if (node.declarations.length > 1) open.push(indent);
334+
join.push(',', newline);
336335
if (node.declarations.length > 1) state.commands.push(dedent);
337336
} else {
338-
join.children.push(', ');
337+
join.push(', ');
339338
}
340339
};
341340

@@ -407,13 +406,13 @@ function sequence(nodes, state, spaces, fn, separator = ',') {
407406
if (multiline) {
408407
state.multiline = true;
409408

410-
open.children.push(indent, newline);
411-
join.children.push(newline);
412-
close.children.push(dedent, newline);
409+
open.push(indent, newline);
410+
join.push(newline);
411+
close.push(dedent, newline);
413412
} else {
414-
if (spaces) open.children.push(' ');
415-
join.children.push(' ');
416-
if (spaces) close.children.push(' ');
413+
if (spaces) open.push(' ');
414+
join.push(' ');
415+
if (spaces) close.push(' ');
417416
}
418417
}
419418

@@ -709,11 +708,11 @@ const shared = {
709708
}
710709

711710
if (multiline) {
712-
open.children.push(indent, newline);
713-
join.children.push(',', newline);
714-
close.children.push(dedent, newline);
711+
open.push(indent, newline);
712+
join.push(',', newline);
713+
close.push(dedent, newline);
715714
} else {
716-
join.children.push(', ');
715+
join.push(', ');
717716
}
718717
},
719718

@@ -905,12 +904,12 @@ const handlers = {
905904
const multiline = child_state.multiline;
906905

907906
if (multiline) {
908-
if_true.children.push(indent, newline, '? ');
909-
if_false.children.push(newline, ': ');
907+
if_true.push(indent, newline, '? ');
908+
if_false.push(newline, ': ');
910909
state.commands.push(dedent);
911910
} else {
912-
if_true.children.push(' ? ');
913-
if_false.children.push(' : ');
911+
if_true.push(' ? ');
912+
if_false.push(' : ');
914913
}
915914
},
916915

0 commit comments

Comments
 (0)