| ... | ... | @@ -2082,60 +2082,62 @@ pub const SrcLoc = struct { |
| 2082 | 2082 | return @bitCast(Ast.Node.Index, offset + @bitCast(i32, src_loc.parent_decl_node)); |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | | pub fn byteOffset(src_loc: SrcLoc, gpa: Allocator) !u32 { |
| 2085 | pub const Span = struct { |
| 2086 | start: u32, |
| 2087 | end: u32, |
| 2088 | }; |
| 2089 | |
| 2090 | pub fn span(src_loc: SrcLoc, gpa: Allocator) !Span { |
| 2086 | 2091 | switch (src_loc.lazy) { |
| 2087 | 2092 | .unneeded => unreachable, |
| 2088 | | .entire_file => return 0, |
| 2093 | .entire_file => return Span{ .start = 0, .end = 1 }, |
| 2089 | 2094 | |
| 2090 | | .byte_abs => |byte_index| return byte_index, |
| 2095 | .byte_abs => |byte_index| return Span{ .start = byte_index, .end = byte_index + 1 }, |
| 2091 | 2096 | |
| 2092 | 2097 | .token_abs => |tok_index| { |
| 2093 | 2098 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2094 | | const token_starts = tree.tokens.items(.start); |
| 2095 | | return token_starts[tok_index]; |
| 2099 | const start = tree.tokens.items(.start)[tok_index]; |
| 2100 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2101 | return Span{ .start = start, .end = end }; |
| 2096 | 2102 | }, |
| 2097 | 2103 | .node_abs => |node| { |
| 2098 | 2104 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2099 | | const token_starts = tree.tokens.items(.start); |
| 2100 | | const tok_index = tree.firstToken(node); |
| 2101 | | return token_starts[tok_index]; |
| 2105 | return nodeToSpan(tree, node); |
| 2102 | 2106 | }, |
| 2103 | 2107 | .byte_offset => |byte_off| { |
| 2104 | 2108 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2105 | | const token_starts = tree.tokens.items(.start); |
| 2106 | | return token_starts[src_loc.declSrcToken()] + byte_off; |
| 2109 | const tok_index = src_loc.declSrcToken(); |
| 2110 | const start = tree.tokens.items(.start)[tok_index] + byte_off; |
| 2111 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2112 | return Span{ .start = start, .end = end }; |
| 2107 | 2113 | }, |
| 2108 | 2114 | .token_offset => |tok_off| { |
| 2109 | 2115 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2110 | 2116 | const tok_index = src_loc.declSrcToken() + tok_off; |
| 2111 | | const token_starts = tree.tokens.items(.start); |
| 2112 | | return token_starts[tok_index]; |
| 2117 | const start = tree.tokens.items(.start)[tok_index]; |
| 2118 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2119 | return Span{ .start = start, .end = end }; |
| 2113 | 2120 | }, |
| 2114 | 2121 | .node_offset => |traced_off| { |
| 2115 | 2122 | const node_off = traced_off.x; |
| 2116 | 2123 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2117 | 2124 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2118 | 2125 | assert(src_loc.file_scope.tree_loaded); |
| 2119 | | const main_tokens = tree.nodes.items(.main_token); |
| 2120 | | const tok_index = main_tokens[node]; |
| 2121 | | const token_starts = tree.tokens.items(.start); |
| 2122 | | return token_starts[tok_index]; |
| 2126 | return nodeToSpan(tree, node); |
| 2123 | 2127 | }, |
| 2124 | 2128 | .node_offset_bin_op => |node_off| { |
| 2125 | 2129 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2126 | 2130 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2127 | 2131 | assert(src_loc.file_scope.tree_loaded); |
| 2128 | | const main_tokens = tree.nodes.items(.main_token); |
| 2129 | | const tok_index = main_tokens[node]; |
| 2130 | | const token_starts = tree.tokens.items(.start); |
| 2131 | | return token_starts[tok_index]; |
| 2132 | return nodeToSpan(tree, node); |
| 2132 | 2133 | }, |
| 2133 | 2134 | .node_offset_back2tok => |node_off| { |
| 2134 | 2135 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2135 | 2136 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2136 | 2137 | const tok_index = tree.firstToken(node) - 2; |
| 2137 | | const token_starts = tree.tokens.items(.start); |
| 2138 | | return token_starts[tok_index]; |
| 2138 | const start = tree.tokens.items(.start)[tok_index]; |
| 2139 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2140 | return Span{ .start = start, .end = end }; |
| 2139 | 2141 | }, |
| 2140 | 2142 | .node_offset_var_decl_ty => |node_off| { |
| 2141 | 2143 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2154,8 +2156,9 @@ pub const SrcLoc = struct { |
| 2154 | 2156 | } else blk: { |
| 2155 | 2157 | break :blk full.ast.mut_token + 1; // the name token |
| 2156 | 2158 | }; |
| 2157 | | const token_starts = tree.tokens.items(.start); |
| 2158 | | return token_starts[tok_index]; |
| 2159 | const start = tree.tokens.items(.start)[tok_index]; |
| 2160 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2161 | return Span{ .start = start, .end = end }; |
| 2159 | 2162 | }, |
| 2160 | 2163 | .node_offset_builtin_call_arg0 => |n| return src_loc.byteOffsetBuiltinCallArg(gpa, n, 0), |
| 2161 | 2164 | .node_offset_builtin_call_arg1 => |n| return src_loc.byteOffsetBuiltinCallArg(gpa, n, 1), |
| ... | ... | @@ -2167,10 +2170,7 @@ pub const SrcLoc = struct { |
| 2167 | 2170 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2168 | 2171 | const node_datas = tree.nodes.items(.data); |
| 2169 | 2172 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2170 | | const main_tokens = tree.nodes.items(.main_token); |
| 2171 | | const tok_index = main_tokens[node_datas[node].rhs]; |
| 2172 | | const token_starts = tree.tokens.items(.start); |
| 2173 | | return token_starts[tok_index]; |
| 2173 | return nodeToSpan(tree, node_datas[node].rhs); |
| 2174 | 2174 | }, |
| 2175 | 2175 | .node_offset_slice_ptr, |
| 2176 | 2176 | .node_offset_slice_start, |
| ... | ... | @@ -2187,7 +2187,7 @@ pub const SrcLoc = struct { |
| 2187 | 2187 | else => unreachable, |
| 2188 | 2188 | }; |
| 2189 | 2189 | const main_tokens = tree.nodes.items(.main_token); |
| 2190 | | const tok_index = main_tokens[ |
| 2190 | const part_node = main_tokens[ |
| 2191 | 2191 | switch (src_loc.lazy) { |
| 2192 | 2192 | .node_offset_slice_ptr => full.ast.sliced, |
| 2193 | 2193 | .node_offset_slice_start => full.ast.start, |
| ... | ... | @@ -2196,8 +2196,7 @@ pub const SrcLoc = struct { |
| 2196 | 2196 | else => unreachable, |
| 2197 | 2197 | } |
| 2198 | 2198 | ]; |
| 2199 | | const token_starts = tree.tokens.items(.start); |
| 2200 | | return token_starts[tok_index]; |
| 2199 | return nodeToSpan(tree, part_node); |
| 2201 | 2200 | }, |
| 2202 | 2201 | .node_offset_call_func => |node_off| { |
| 2203 | 2202 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2219,10 +2218,7 @@ pub const SrcLoc = struct { |
| 2219 | 2218 | |
| 2220 | 2219 | else => unreachable, |
| 2221 | 2220 | }; |
| 2222 | | const main_tokens = tree.nodes.items(.main_token); |
| 2223 | | const tok_index = main_tokens[full.ast.fn_expr]; |
| 2224 | | const token_starts = tree.tokens.items(.start); |
| 2225 | | return token_starts[tok_index]; |
| 2221 | return nodeToSpan(tree, full.ast.fn_expr); |
| 2226 | 2222 | }, |
| 2227 | 2223 | .node_offset_field_name => |node_off| { |
| 2228 | 2224 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2233,16 +2229,14 @@ pub const SrcLoc = struct { |
| 2233 | 2229 | .field_access => node_datas[node].rhs, |
| 2234 | 2230 | else => tree.firstToken(node) - 2, |
| 2235 | 2231 | }; |
| 2236 | | const token_starts = tree.tokens.items(.start); |
| 2237 | | return token_starts[tok_index]; |
| 2232 | const start = tree.tokens.items(.start)[tok_index]; |
| 2233 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2234 | return Span{ .start = start, .end = end }; |
| 2238 | 2235 | }, |
| 2239 | 2236 | .node_offset_deref_ptr => |node_off| { |
| 2240 | 2237 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2241 | | const node_datas = tree.nodes.items(.data); |
| 2242 | 2238 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2243 | | const tok_index = node_datas[node].lhs; |
| 2244 | | const token_starts = tree.tokens.items(.start); |
| 2245 | | return token_starts[tok_index]; |
| 2239 | return nodeToSpan(tree, node); |
| 2246 | 2240 | }, |
| 2247 | 2241 | .node_offset_asm_source => |node_off| { |
| 2248 | 2242 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2253,10 +2247,7 @@ pub const SrcLoc = struct { |
| 2253 | 2247 | .@"asm" => tree.asmFull(node), |
| 2254 | 2248 | else => unreachable, |
| 2255 | 2249 | }; |
| 2256 | | const main_tokens = tree.nodes.items(.main_token); |
| 2257 | | const tok_index = main_tokens[full.ast.template]; |
| 2258 | | const token_starts = tree.tokens.items(.start); |
| 2259 | | return token_starts[tok_index]; |
| 2250 | return nodeToSpan(tree, full.ast.template); |
| 2260 | 2251 | }, |
| 2261 | 2252 | .node_offset_asm_ret_ty => |node_off| { |
| 2262 | 2253 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2269,11 +2260,7 @@ pub const SrcLoc = struct { |
| 2269 | 2260 | }; |
| 2270 | 2261 | const asm_output = full.outputs[0]; |
| 2271 | 2262 | const node_datas = tree.nodes.items(.data); |
| 2272 | | const ret_ty_node = node_datas[asm_output].lhs; |
| 2273 | | const main_tokens = tree.nodes.items(.main_token); |
| 2274 | | const tok_index = main_tokens[ret_ty_node]; |
| 2275 | | const token_starts = tree.tokens.items(.start); |
| 2276 | | return token_starts[tok_index]; |
| 2263 | return nodeToSpan(tree, node_datas[asm_output].lhs); |
| 2277 | 2264 | }, |
| 2278 | 2265 | |
| 2279 | 2266 | .node_offset_for_cond, .node_offset_if_cond => |node_off| { |
| ... | ... | @@ -2290,41 +2277,26 @@ pub const SrcLoc = struct { |
| 2290 | 2277 | .@"for" => tree.forFull(node).ast.cond_expr, |
| 2291 | 2278 | else => unreachable, |
| 2292 | 2279 | }; |
| 2293 | | const main_tokens = tree.nodes.items(.main_token); |
| 2294 | | const tok_index = main_tokens[src_node]; |
| 2295 | | const token_starts = tree.tokens.items(.start); |
| 2296 | | return token_starts[tok_index]; |
| 2280 | return nodeToSpan(tree, src_node); |
| 2297 | 2281 | }, |
| 2298 | 2282 | .node_offset_bin_lhs => |node_off| { |
| 2299 | 2283 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2300 | 2284 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2301 | 2285 | const node_datas = tree.nodes.items(.data); |
| 2302 | | const src_node = node_datas[node].lhs; |
| 2303 | | const main_tokens = tree.nodes.items(.main_token); |
| 2304 | | const tok_index = main_tokens[src_node]; |
| 2305 | | const token_starts = tree.tokens.items(.start); |
| 2306 | | return token_starts[tok_index]; |
| 2286 | return nodeToSpan(tree, node_datas[node].lhs); |
| 2307 | 2287 | }, |
| 2308 | 2288 | .node_offset_bin_rhs => |node_off| { |
| 2309 | 2289 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2310 | 2290 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2311 | 2291 | const node_datas = tree.nodes.items(.data); |
| 2312 | | const src_node = node_datas[node].rhs; |
| 2313 | | const main_tokens = tree.nodes.items(.main_token); |
| 2314 | | const tok_index = main_tokens[src_node]; |
| 2315 | | const token_starts = tree.tokens.items(.start); |
| 2316 | | return token_starts[tok_index]; |
| 2292 | return nodeToSpan(tree, node_datas[node].rhs); |
| 2317 | 2293 | }, |
| 2318 | 2294 | |
| 2319 | 2295 | .node_offset_switch_operand => |node_off| { |
| 2320 | 2296 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2321 | 2297 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2322 | 2298 | const node_datas = tree.nodes.items(.data); |
| 2323 | | const src_node = node_datas[node].lhs; |
| 2324 | | const main_tokens = tree.nodes.items(.main_token); |
| 2325 | | const tok_index = main_tokens[src_node]; |
| 2326 | | const token_starts = tree.tokens.items(.start); |
| 2327 | | return token_starts[tok_index]; |
| 2299 | return nodeToSpan(tree, node_datas[node].lhs); |
| 2328 | 2300 | }, |
| 2329 | 2301 | |
| 2330 | 2302 | .node_offset_switch_special_prong => |node_off| { |
| ... | ... | @@ -2347,9 +2319,7 @@ pub const SrcLoc = struct { |
| 2347 | 2319 | mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_")); |
| 2348 | 2320 | if (!is_special) continue; |
| 2349 | 2321 | |
| 2350 | | const tok_index = main_tokens[case_node]; |
| 2351 | | const token_starts = tree.tokens.items(.start); |
| 2352 | | return token_starts[tok_index]; |
| 2322 | return nodeToSpan(tree, case_node); |
| 2353 | 2323 | } else unreachable; |
| 2354 | 2324 | }, |
| 2355 | 2325 | |
| ... | ... | @@ -2375,9 +2345,7 @@ pub const SrcLoc = struct { |
| 2375 | 2345 | |
| 2376 | 2346 | for (case.ast.values) |item_node| { |
| 2377 | 2347 | if (node_tags[item_node] == .switch_range) { |
| 2378 | | const tok_index = main_tokens[item_node]; |
| 2379 | | const token_starts = tree.tokens.items(.start); |
| 2380 | | return token_starts[tok_index]; |
| 2348 | return nodeToSpan(tree, item_node); |
| 2381 | 2349 | } |
| 2382 | 2350 | } |
| 2383 | 2351 | } else unreachable; |
| ... | ... | @@ -2403,10 +2371,7 @@ pub const SrcLoc = struct { |
| 2403 | 2371 | }, |
| 2404 | 2372 | else => unreachable, |
| 2405 | 2373 | }; |
| 2406 | | const main_tokens = tree.nodes.items(.main_token); |
| 2407 | | const tok_index = main_tokens[full.ast.callconv_expr]; |
| 2408 | | const token_starts = tree.tokens.items(.start); |
| 2409 | | return token_starts[tok_index]; |
| 2374 | return nodeToSpan(tree, full.ast.callconv_expr); |
| 2410 | 2375 | }, |
| 2411 | 2376 | |
| 2412 | 2377 | .node_offset_fn_type_ret_ty => |node_off| { |
| ... | ... | @@ -2421,21 +2386,14 @@ pub const SrcLoc = struct { |
| 2421 | 2386 | .fn_proto => tree.fnProto(node), |
| 2422 | 2387 | else => unreachable, |
| 2423 | 2388 | }; |
| 2424 | | const main_tokens = tree.nodes.items(.main_token); |
| 2425 | | const tok_index = main_tokens[full.ast.return_type]; |
| 2426 | | const token_starts = tree.tokens.items(.start); |
| 2427 | | return token_starts[tok_index]; |
| 2389 | return nodeToSpan(tree, full.ast.return_type); |
| 2428 | 2390 | }, |
| 2429 | 2391 | |
| 2430 | 2392 | .node_offset_anyframe_type => |node_off| { |
| 2431 | 2393 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2432 | 2394 | const node_datas = tree.nodes.items(.data); |
| 2433 | 2395 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2434 | | const node = node_datas[parent_node].rhs; |
| 2435 | | const main_tokens = tree.nodes.items(.main_token); |
| 2436 | | const tok_index = main_tokens[node]; |
| 2437 | | const token_starts = tree.tokens.items(.start); |
| 2438 | | return token_starts[tok_index]; |
| 2396 | return nodeToSpan(tree, node_datas[parent_node].rhs); |
| 2439 | 2397 | }, |
| 2440 | 2398 | |
| 2441 | 2399 | .node_offset_lib_name => |node_off| { |
| ... | ... | @@ -2462,8 +2420,9 @@ pub const SrcLoc = struct { |
| 2462 | 2420 | else => unreachable, |
| 2463 | 2421 | }; |
| 2464 | 2422 | const tok_index = full.lib_name.?; |
| 2465 | | const token_starts = tree.tokens.items(.start); |
| 2466 | | return token_starts[tok_index]; |
| 2423 | const start = tree.tokens.items(.start)[tok_index]; |
| 2424 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| 2425 | return Span{ .start = start, .end = end }; |
| 2467 | 2426 | }, |
| 2468 | 2427 | |
| 2469 | 2428 | .node_offset_array_type_len => |node_off| { |
| ... | ... | @@ -2476,11 +2435,7 @@ pub const SrcLoc = struct { |
| 2476 | 2435 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), |
| 2477 | 2436 | else => unreachable, |
| 2478 | 2437 | }; |
| 2479 | | const node = full.ast.elem_count; |
| 2480 | | const main_tokens = tree.nodes.items(.main_token); |
| 2481 | | const tok_index = main_tokens[node]; |
| 2482 | | const token_starts = tree.tokens.items(.start); |
| 2483 | | return token_starts[tok_index]; |
| 2438 | return nodeToSpan(tree, full.ast.elem_count); |
| 2484 | 2439 | }, |
| 2485 | 2440 | .node_offset_array_type_sentinel => |node_off| { |
| 2486 | 2441 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2492,11 +2447,7 @@ pub const SrcLoc = struct { |
| 2492 | 2447 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), |
| 2493 | 2448 | else => unreachable, |
| 2494 | 2449 | }; |
| 2495 | | const node = full.ast.sentinel; |
| 2496 | | const main_tokens = tree.nodes.items(.main_token); |
| 2497 | | const tok_index = main_tokens[node]; |
| 2498 | | const token_starts = tree.tokens.items(.start); |
| 2499 | | return token_starts[tok_index]; |
| 2450 | return nodeToSpan(tree, full.ast.sentinel); |
| 2500 | 2451 | }, |
| 2501 | 2452 | .node_offset_array_type_elem => |node_off| { |
| 2502 | 2453 | const tree = try src_loc.file_scope.getTree(gpa); |
| ... | ... | @@ -2508,21 +2459,14 @@ pub const SrcLoc = struct { |
| 2508 | 2459 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), |
| 2509 | 2460 | else => unreachable, |
| 2510 | 2461 | }; |
| 2511 | | const node = full.ast.elem_type; |
| 2512 | | const main_tokens = tree.nodes.items(.main_token); |
| 2513 | | const tok_index = main_tokens[node]; |
| 2514 | | const token_starts = tree.tokens.items(.start); |
| 2515 | | return token_starts[tok_index]; |
| 2462 | return nodeToSpan(tree, full.ast.elem_type); |
| 2516 | 2463 | }, |
| 2517 | 2464 | .node_offset_un_op => |node_off| { |
| 2518 | 2465 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2519 | 2466 | const node_datas = tree.nodes.items(.data); |
| 2520 | 2467 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2521 | 2468 | |
| 2522 | | const main_tokens = tree.nodes.items(.main_token); |
| 2523 | | const tok_index = main_tokens[node_datas[node].lhs]; |
| 2524 | | const token_starts = tree.tokens.items(.start); |
| 2525 | | return token_starts[tok_index]; |
| 2469 | return nodeToSpan(tree, node_datas[node].lhs); |
| 2526 | 2470 | }, |
| 2527 | 2471 | } |
| 2528 | 2472 | } |
| ... | ... | @@ -2532,7 +2476,7 @@ pub const SrcLoc = struct { |
| 2532 | 2476 | gpa: Allocator, |
| 2533 | 2477 | node_off: i32, |
| 2534 | 2478 | arg_index: u32, |
| 2535 | | ) !u32 { |
| 2479 | ) !Span { |
| 2536 | 2480 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2537 | 2481 | const node_datas = tree.nodes.items(.data); |
| 2538 | 2482 | const node_tags = tree.nodes.items(.tag); |
| ... | ... | @@ -2546,10 +2490,33 @@ pub const SrcLoc = struct { |
| 2546 | 2490 | .builtin_call, .builtin_call_comma => tree.extra_data[node_datas[node].lhs + arg_index], |
| 2547 | 2491 | else => unreachable, |
| 2548 | 2492 | }; |
| 2549 | | const main_tokens = tree.nodes.items(.main_token); |
| 2550 | | const tok_index = main_tokens[param]; |
| 2493 | return nodeToSpan(tree, param); |
| 2494 | } |
| 2495 | |
| 2496 | pub fn nodeToSpan(tree: *const Ast, node: u32) Span { |
| 2551 | 2497 | const token_starts = tree.tokens.items(.start); |
| 2552 | | return token_starts[tok_index]; |
| 2498 | const start = tree.firstToken(node); |
| 2499 | const end = tree.lastToken(node); |
| 2500 | if (tree.tokensOnSameLine(start, end)) { |
| 2501 | const start_off = token_starts[start]; |
| 2502 | const end_off = token_starts[end] + @intCast(u32, tree.tokenSlice(end).len); |
| 2503 | return Span{ .start = start_off, .end = end_off }; |
| 2504 | } |
| 2505 | |
| 2506 | const main_token = tree.nodes.items(.main_token)[node]; |
| 2507 | if (tree.tokensOnSameLine(start, main_token)) { |
| 2508 | const start_off = token_starts[start]; |
| 2509 | const end_off = token_starts[main_token] + @intCast(u32, tree.tokenSlice(main_token).len); |
| 2510 | return Span{ .start = start_off, .end = end_off }; |
| 2511 | } |
| 2512 | if (tree.tokensOnSameLine(main_token, end)) { |
| 2513 | const start_off = token_starts[main_token]; |
| 2514 | const end_off = token_starts[end] + @intCast(u32, tree.tokenSlice(end).len); |
| 2515 | return Span{ .start = start_off, .end = end_off }; |
| 2516 | } |
| 2517 | const start_off = token_starts[main_token]; |
| 2518 | const end_off = token_starts[main_token] + @intCast(u32, tree.tokenSlice(main_token).len); |
| 2519 | return Span{ .start = start_off, .end = end_off }; |
| 2553 | 2520 | } |
| 2554 | 2521 | }; |
| 2555 | 2522 | |
| ... | ... | @@ -3313,7 +3280,11 @@ pub fn astGenFile(mod: *Module, file: *File) !void { |
| 3313 | 3280 | .src_loc = .{ |
| 3314 | 3281 | .file_scope = file, |
| 3315 | 3282 | .parent_decl_node = 0, |
| 3316 | | .lazy = .{ .byte_abs = token_starts[parse_err.token] + extra_offset }, |
| 3283 | .lazy = if (extra_offset == 0) .{ |
| 3284 | .token_abs = parse_err.token, |
| 3285 | } else .{ |
| 3286 | .byte_abs = token_starts[parse_err.token], |
| 3287 | }, |
| 3317 | 3288 | }, |
| 3318 | 3289 | .msg = msg.toOwnedSlice(), |
| 3319 | 3290 | }; |
| ... | ... | @@ -3336,7 +3307,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void { |
| 3336 | 3307 | .src_loc = .{ |
| 3337 | 3308 | .file_scope = file, |
| 3338 | 3309 | .parent_decl_node = 0, |
| 3339 | | .lazy = .{ .byte_abs = token_starts[note.token] }, |
| 3310 | .lazy = .{ .token_abs = note.token }, |
| 3340 | 3311 | }, |
| 3341 | 3312 | .msg = msg.toOwnedSlice(), |
| 3342 | 3313 | }; |