| ... | @@ -205,9 +205,11 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T { | ... | @@ -205,9 +205,11 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T { |
| 205 | } | 205 | } |
| 206 | | 206 | |
| 207 | pub fn rootDecls(tree: Ast) []const Node.Index { | 207 | pub fn rootDecls(tree: Ast) []const Node.Index { |
| 208 | // Root is always index 0. | | |
| 209 | const nodes_data = tree.nodes.items(.data); | 208 | const nodes_data = tree.nodes.items(.data); |
| 210 | return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs]; | 209 | return switch (tree.mode) { |
| | 210 | .zig => tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs], |
| | 211 | .zon => (&nodes_data[0].lhs)[0..1], |
| | 212 | }; |
| 211 | } | 213 | } |
| 212 | | 214 | |
| 213 | pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { | 215 | pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { |