| ... | ... | @@ -2106,38 +2106,3 @@ fn nodeCausesSliceOpSpace(tag: ast.Node.Tag) bool { |
| 2106 | 2106 | else => false, |
| 2107 | 2107 | }; |
| 2108 | 2108 | } |
| 2109 | | |
| 2110 | | fn copyFixingWhitespace(ais: *Ais, slice: []const u8) @TypeOf(ais.*).Error!void { |
| 2111 | | const writer = ais.writer(); |
| 2112 | | for (slice) |byte| switch (byte) { |
| 2113 | | '\t' => try writer.writeAll(" "), |
| 2114 | | '\r' => {}, |
| 2115 | | else => try writer.writeByte(byte), |
| 2116 | | }; |
| 2117 | | } |
| 2118 | | |
| 2119 | | // Returns the number of nodes in `expr` that are on the same line as `rtoken`, |
| 2120 | | // or null if they all are on the same line. |
| 2121 | | fn rowSize(tree: ast.Tree, exprs: []ast.Node.Index, rtoken: ast.TokenIndex) ?usize { |
| 2122 | | const first_token = exprs[0].firstToken(); |
| 2123 | | const first_loc = tree.tokenLocation(tree.token_locs[first_token].start, rtoken); |
| 2124 | | if (first_loc.line == 0) { |
| 2125 | | const maybe_comma = tree.prevToken(rtoken); |
| 2126 | | if (tree.token_tags[maybe_comma] == .Comma) |
| 2127 | | return 1; |
| 2128 | | return null; // no newlines |
| 2129 | | } |
| 2130 | | |
| 2131 | | var count: usize = 1; |
| 2132 | | for (exprs) |expr, i| { |
| 2133 | | if (i + 1 < exprs.len) { |
| 2134 | | const expr_last_token = expr.lastToken() + 1; |
| 2135 | | const loc = tree.tokenLocation(tree.token_locs[expr_last_token].start, exprs[i + 1].firstToken()); |
| 2136 | | if (loc.line != 0) return count; |
| 2137 | | count += 1; |
| 2138 | | } else { |
| 2139 | | return count; |
| 2140 | | } |
| 2141 | | } |
| 2142 | | unreachable; |
| 2143 | | } |