|
793 | 793 | }
|
794 | 794 |
|
795 | 795 | if (arrow) {
|
796 |
| - result.push(space, '=>'); |
| 796 | + result.push(space); |
| 797 | + result.push('=>'); |
797 | 798 | }
|
798 | 799 |
|
799 | 800 | if (node.expression) {
|
|
818 | 819 | withIndent(function () {
|
819 | 820 | if (stmt.left.type === Syntax.VariableDeclaration) {
|
820 | 821 | withIndent(function () {
|
821 |
| - result.push(stmt.left.kind + noEmptySpace(), generateStatement(stmt.left.declarations[0], { |
| 822 | + result.push(stmt.left.kind + noEmptySpace()); |
| 823 | + result.push(generateStatement(stmt.left.declarations[0], { |
822 | 824 | allowIn: false
|
823 | 825 | }));
|
824 | 826 | });
|
|
971 | 973 | if (expr.operator === '/' && fragment.toString().charAt(0) === '/' ||
|
972 | 974 | expr.operator.slice(-1) === '<' && fragment.toString().slice(0, 3) === '!--') {
|
973 | 975 | // If '/' concats with '/' or `<` concats with `!--`, it is interpreted as comment start
|
974 |
| - result.push(noEmptySpace(), fragment); |
| 976 | + result.push(noEmptySpace()); |
| 977 | + result.push(fragment); |
975 | 978 | } else {
|
976 | 979 | result = join(result, fragment);
|
977 | 980 | }
|
|
1053 | 1056 | })];
|
1054 | 1057 |
|
1055 | 1058 | if (expr.computed) {
|
1056 |
| - result.push('[', generateExpression(expr.property, { |
| 1059 | + result.push('['); |
| 1060 | + result.push(generateExpression(expr.property, { |
1057 | 1061 | precedence: Precedence.Sequence,
|
1058 | 1062 | allowIn: true,
|
1059 | 1063 | allowCall: allowCall
|
1060 |
| - }), ']'); |
| 1064 | + })); |
| 1065 | + result.push(']'); |
1061 | 1066 | } else {
|
1062 | 1067 | if (expr.object.type === Syntax.Literal && typeof expr.object.value === 'number') {
|
1063 | 1068 | fragment = toSourceNodeWhenNeeded(result).toString();
|
|
1076 | 1081 | result.push('.');
|
1077 | 1082 | }
|
1078 | 1083 | }
|
1079 |
| - result.push('.', generateIdentifier(expr.property)); |
| 1084 | + result.push('.'); |
| 1085 | + result.push(generateIdentifier(expr.property)); |
1080 | 1086 | }
|
1081 | 1087 |
|
1082 | 1088 | result = parenthesize(result, Precedence.Member, precedence);
|
|
1106 | 1112 |
|
1107 | 1113 | if (((leftCharCode === 0x2B /* + */ || leftCharCode === 0x2D /* - */) && leftCharCode === rightCharCode) ||
|
1108 | 1114 | (esutils.code.isIdentifierPart(leftCharCode) && esutils.code.isIdentifierPart(rightCharCode))) {
|
1109 |
| - result.push(noEmptySpace(), fragment); |
| 1115 | + result.push(noEmptySpace()); |
| 1116 | + result.push(fragment); |
1110 | 1117 | } else {
|
1111 | 1118 | result.push(fragment);
|
1112 | 1119 | }
|
|
1196 | 1203 | result.push(',');
|
1197 | 1204 | }
|
1198 | 1205 | } else {
|
1199 |
| - result.push(multiline ? indent : '', generateExpression(expr.elements[i], { |
| 1206 | + result.push(multiline ? indent : ''); |
| 1207 | + result.push(generateExpression(expr.elements[i], { |
1200 | 1208 | precedence: Precedence.Assignment,
|
1201 | 1209 | allowIn: true,
|
1202 | 1210 | allowCall: true
|
|
1210 | 1218 | if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) {
|
1211 | 1219 | result.push(newline);
|
1212 | 1220 | }
|
1213 |
| - result.push(multiline ? base : '', ']'); |
| 1221 | + result.push(multiline ? base : ''); |
| 1222 | + result.push(']'); |
1214 | 1223 | break;
|
1215 | 1224 |
|
1216 | 1225 | case Syntax.Property:
|
|
1240 | 1249 | precedence: Precedence.Sequence,
|
1241 | 1250 | allowIn: true,
|
1242 | 1251 | allowCall: true
|
1243 |
| - }), generateFunctionBody(expr.value)); |
| 1252 | + })); |
| 1253 | + result.push(generateFunctionBody(expr.value)); |
1244 | 1254 | } else {
|
1245 | 1255 | result = [
|
1246 | 1256 | generateExpression(expr.key, {
|
|
1296 | 1306 | if (multiline) {
|
1297 | 1307 | result.push(',' + newline);
|
1298 | 1308 | for (i = 1, len = expr.properties.length; i < len; ++i) {
|
1299 |
| - result.push(indent, generateExpression(expr.properties[i], { |
| 1309 | + result.push(indent); |
| 1310 | + result.push(generateExpression(expr.properties[i], { |
1300 | 1311 | precedence: Precedence.Sequence,
|
1301 | 1312 | allowIn: true,
|
1302 | 1313 | allowCall: true,
|
|
1312 | 1323 | if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) {
|
1313 | 1324 | result.push(newline);
|
1314 | 1325 | }
|
1315 |
| - result.push(base, '}'); |
| 1326 | + result.push(base); |
| 1327 | + result.push('}'); |
1316 | 1328 | break;
|
1317 | 1329 |
|
1318 | 1330 | case Syntax.ObjectPattern:
|
|
1340 | 1352 |
|
1341 | 1353 | withIndent(function (indent) {
|
1342 | 1354 | for (i = 0, len = expr.properties.length; i < len; ++i) {
|
1343 |
| - result.push(multiline ? indent : '', generateExpression(expr.properties[i], { |
| 1355 | + result.push(multiline ? indent : ''); |
| 1356 | + result.push(generateExpression(expr.properties[i], { |
1344 | 1357 | precedence: Precedence.Sequence,
|
1345 | 1358 | allowIn: true,
|
1346 | 1359 | allowCall: true
|
|
1354 | 1367 | if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) {
|
1355 | 1368 | result.push(newline);
|
1356 | 1369 | }
|
1357 |
| - result.push(multiline ? base : '', '}'); |
| 1370 | + result.push(multiline ? base : ''); |
| 1371 | + result.push('}'); |
1358 | 1372 | break;
|
1359 | 1373 |
|
1360 | 1374 | case Syntax.ThisExpression:
|
|
1679 | 1693 | // };
|
1680 | 1694 | if (stmt.declarations.length === 1 && stmt.declarations[0].init &&
|
1681 | 1695 | stmt.declarations[0].init.type === Syntax.FunctionExpression) {
|
1682 |
| - result.push(noEmptySpace(), generateStatement(stmt.declarations[0], { |
| 1696 | + result.push(noEmptySpace()); |
| 1697 | + result.push(generateStatement(stmt.declarations[0], { |
1683 | 1698 | allowIn: allowIn
|
1684 | 1699 | }));
|
1685 | 1700 | } else {
|
|
1689 | 1704 | withIndent(function () {
|
1690 | 1705 | node = stmt.declarations[0];
|
1691 | 1706 | if (extra.comment && node.leadingComments) {
|
1692 |
| - result.push('\n', addIndent(generateStatement(node, { |
| 1707 | + result.push('\n'); |
| 1708 | + result.push(addIndent(generateStatement(node, { |
1693 | 1709 | allowIn: allowIn
|
1694 | 1710 | })));
|
1695 | 1711 | } else {
|
1696 |
| - result.push(noEmptySpace(), generateStatement(node, { |
| 1712 | + result.push(noEmptySpace()); |
| 1713 | + result.push(generateStatement(node, { |
1697 | 1714 | allowIn: allowIn
|
1698 | 1715 | }));
|
1699 | 1716 | }
|
1700 | 1717 |
|
1701 | 1718 | for (i = 1, len = stmt.declarations.length; i < len; ++i) {
|
1702 | 1719 | node = stmt.declarations[i];
|
1703 | 1720 | if (extra.comment && node.leadingComments) {
|
1704 |
| - result.push(',' + newline, addIndent(generateStatement(node, { |
| 1721 | + result.push(',' + newline); |
| 1722 | + result.push(addIndent(generateStatement(node, { |
1705 | 1723 | allowIn: allowIn
|
1706 | 1724 | })));
|
1707 | 1725 | } else {
|
1708 |
| - result.push(',' + space, generateStatement(node, { |
| 1726 | + result.push(',' + space); |
| 1727 | + result.push(generateStatement(node, { |
1709 | 1728 | allowIn: allowIn
|
1710 | 1729 | }));
|
1711 | 1730 | }
|
|
1867 | 1886 | precedence: Precedence.Sequence,
|
1868 | 1887 | allowIn: false,
|
1869 | 1888 | allowCall: true
|
1870 |
| - }), ';'); |
| 1889 | + })); |
| 1890 | + result.push(';'); |
1871 | 1891 | }
|
1872 | 1892 | } else {
|
1873 | 1893 | result.push(';');
|
1874 | 1894 | }
|
1875 | 1895 |
|
1876 | 1896 | if (stmt.test) {
|
1877 |
| - result.push(space, generateExpression(stmt.test, { |
| 1897 | + result.push(space); |
| 1898 | + result.push(generateExpression(stmt.test, { |
1878 | 1899 | precedence: Precedence.Sequence,
|
1879 | 1900 | allowIn: true,
|
1880 | 1901 | allowCall: true
|
1881 |
| - }), ';'); |
| 1902 | + })); |
| 1903 | + result.push(';'); |
1882 | 1904 | } else {
|
1883 | 1905 | result.push(';');
|
1884 | 1906 | }
|
1885 | 1907 |
|
1886 | 1908 | if (stmt.update) {
|
1887 |
| - result.push(space, generateExpression(stmt.update, { |
| 1909 | + result.push(space); |
| 1910 | + result.push(generateExpression(stmt.update, { |
1888 | 1911 | precedence: Precedence.Sequence,
|
1889 | 1912 | allowIn: true,
|
1890 | 1913 | allowCall: true
|
1891 |
| - }), ')'); |
| 1914 | + })); |
| 1915 | + result.push(')'); |
1892 | 1916 | } else {
|
1893 | 1917 | result.push(')');
|
1894 | 1918 | }
|
|
0 commit comments