| ... | @@ -1058,21 +1058,22 @@ fn renderExpression( | ... | @@ -1058,21 +1058,22 @@ fn renderExpression( |
| 1058 | }; | 1058 | }; |
| 1059 | | 1059 | |
| 1060 | if (src_has_trailing_comma) { | 1060 | if (src_has_trailing_comma) { |
| 1061 | try renderToken(tree, ais, lparen, Space.Newline); | 1061 | { |
| 1062 | | | |
| 1063 | const params = call.params(); | | |
| 1064 | for (params) |param_node, i| { | | |
| 1065 | ais.pushIndent(); | 1062 | ais.pushIndent(); |
| 1066 | defer ais.popIndent(); | 1063 | defer ais.popIndent(); |
| 1067 | | 1064 | |
| 1068 | if (i + 1 < params.len) { | 1065 | try renderToken(tree, ais, lparen, Space.Newline); // ( |
| 1069 | const next_node = params[i + 1]; | 1066 | const params = call.params(); |
| 1070 | try renderExpression(allocator, ais, tree, param_node, Space.None); | 1067 | for (params) |param_node, i| { |
| 1071 | const comma = tree.nextToken(param_node.lastToken()); | 1068 | if (i + 1 < params.len) { |
| 1072 | try renderToken(tree, ais, comma, Space.Newline); // , | 1069 | const next_node = params[i + 1]; |
| 1073 | try renderExtraNewline(tree, ais, next_node); | 1070 | try renderExpression(allocator, ais, tree, param_node, Space.None); |
| 1074 | } else { | 1071 | const comma = tree.nextToken(param_node.lastToken()); |
| 1075 | try renderExpression(allocator, ais, tree, param_node, Space.Comma); | 1072 | try renderToken(tree, ais, comma, Space.Newline); // , |
| | 1073 | try renderExtraNewline(tree, ais, next_node); |
| | 1074 | } else { |
| | 1075 | try renderExpression(allocator, ais, tree, param_node, Space.Comma); |
| | 1076 | } |
| 1076 | } | 1077 | } |
| 1077 | } | 1078 | } |
| 1078 | return renderToken(tree, ais, call.rtoken, space); | 1079 | return renderToken(tree, ais, call.rtoken, space); |
| ... | @@ -1082,7 +1083,10 @@ fn renderExpression( | ... | @@ -1082,7 +1083,10 @@ fn renderExpression( |
| 1082 | | 1083 | |
| 1083 | const params = call.params(); | 1084 | const params = call.params(); |
| 1084 | for (params) |param_node, i| { | 1085 | for (params) |param_node, i| { |
| 1085 | if (param_node.*.tag == .MultilineStringLiteral) ais.pushIndentOneShot(); | 1086 | const maybe_comment = param_node.firstToken() - 1; |
| | 1087 | if (param_node.*.tag == .MultilineStringLiteral or tree.token_ids[maybe_comment] == .LineComment) { |
| | 1088 | ais.pushIndentOneShot(); |
| | 1089 | } |
| 1086 | | 1090 | |
| 1087 | try renderExpression(allocator, ais, tree, param_node, Space.None); | 1091 | try renderExpression(allocator, ais, tree, param_node, Space.None); |
| 1088 | | 1092 | |
| ... | @@ -1092,7 +1096,7 @@ fn renderExpression( | ... | @@ -1092,7 +1096,7 @@ fn renderExpression( |
| 1092 | try renderToken(tree, ais, comma, Space.Space); | 1096 | try renderToken(tree, ais, comma, Space.Space); |
| 1093 | } | 1097 | } |
| 1094 | } | 1098 | } |
| 1095 | return renderToken(tree, ais, call.rtoken, space); | 1099 | return renderToken(tree, ais, call.rtoken, space); // ) |
| 1096 | }, | 1100 | }, |
| 1097 | | 1101 | |
| 1098 | .ArrayAccess => { | 1102 | .ArrayAccess => { |
| ... | @@ -1497,6 +1501,10 @@ fn renderExpression( | ... | @@ -1497,6 +1501,10 @@ fn renderExpression( |
| 1497 | // render all on one line, no trailing comma | 1501 | // render all on one line, no trailing comma |
| 1498 | const params = builtin_call.params(); | 1502 | const params = builtin_call.params(); |
| 1499 | for (params) |param_node, i| { | 1503 | for (params) |param_node, i| { |
| | 1504 | const maybe_comment = param_node.firstToken() - 1; |
| | 1505 | if (param_node.*.tag == .MultilineStringLiteral or tree.token_ids[maybe_comment] == .LineComment) { |
| | 1506 | ais.pushIndentOneShot(); |
| | 1507 | } |
| 1500 | try renderExpression(allocator, ais, tree, param_node, Space.None); | 1508 | try renderExpression(allocator, ais, tree, param_node, Space.None); |
| 1501 | | 1509 | |
| 1502 | if (i + 1 < params.len) { | 1510 | if (i + 1 < params.len) { |
| ... | @@ -1548,19 +1556,20 @@ fn renderExpression( | ... | @@ -1548,19 +1556,20 @@ fn renderExpression( |
| 1548 | assert(tree.token_ids[lparen] == .LParen); | 1556 | assert(tree.token_ids[lparen] == .LParen); |
| 1549 | | 1557 | |
| 1550 | const rparen = tree.prevToken( | 1558 | const rparen = tree.prevToken( |
| 1551 | // the first token for the annotation expressions is the left | 1559 | // the first token for the annotation expressions is the left |
| 1552 | // parenthesis, hence the need for two prevToken | 1560 | // parenthesis, hence the need for two prevToken |
| 1553 | if (fn_proto.getAlignExpr()) |align_expr| | 1561 | if (fn_proto.getAlignExpr()) |align_expr| |
| 1554 | tree.prevToken(tree.prevToken(align_expr.firstToken())) | 1562 | tree.prevToken(tree.prevToken(align_expr.firstToken())) |
| 1555 | else if (fn_proto.getSectionExpr()) |section_expr| | 1563 | else if (fn_proto.getSectionExpr()) |section_expr| |
| 1556 | tree.prevToken(tree.prevToken(section_expr.firstToken())) | 1564 | tree.prevToken(tree.prevToken(section_expr.firstToken())) |
| 1557 | else if (fn_proto.getCallconvExpr()) |callconv_expr| | 1565 | else if (fn_proto.getCallconvExpr()) |callconv_expr| |
| 1558 | tree.prevToken(tree.prevToken(callconv_expr.firstToken())) | 1566 | tree.prevToken(tree.prevToken(callconv_expr.firstToken())) |
| 1559 | else switch (fn_proto.return_type) { | 1567 | else switch (fn_proto.return_type) { |
| 1560 | .Explicit => |node| node.firstToken(), | 1568 | .Explicit => |node| node.firstToken(), |
| 1561 | .InferErrorSet => |node| tree.prevToken(node.firstToken()), | 1569 | .InferErrorSet => |node| tree.prevToken(node.firstToken()), |
| 1562 | .Invalid => unreachable, | 1570 | .Invalid => unreachable, |
| 1563 | }); | 1571 | }, |
| | 1572 | ); |
| 1564 | assert(tree.token_ids[rparen] == .RParen); | 1573 | assert(tree.token_ids[rparen] == .RParen); |
| 1565 | | 1574 | |
| 1566 | const src_params_trailing_comma = blk: { | 1575 | const src_params_trailing_comma = blk: { |