Skip to content

Commit

Permalink
Tree: handle builtin call expressions in childNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Dec 2, 2024
1 parent d80080e commit 4445565
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/aro/Tree.zig
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,16 @@ pub fn childNodes(tree: *const Tree, node: NodeIndex) []const NodeIndex {
const range = data[@intFromEnum(node)].range;
return tree.data[range.start..range.end];
},
.builtin_call_expr => {
const range = data[@intFromEnum(node)].range;
return tree.data[range.start + 1 .. range.end];
},
.builtin_call_expr_one => {
const ptr: [*]const NodeIndex = @ptrCast(&data[@intFromEnum(node)].decl.node);
const slice = ptr[0..1];
const end = std.mem.indexOfScalar(NodeIndex, slice, .none) orelse 1;
return slice[0..end];
},
else => unreachable,
}
}
Expand Down Expand Up @@ -1273,18 +1283,22 @@ fn dumpNode(

try w.writeByteNTimes(' ', level + half);
try w.writeAll("args:\n");
for (tree.data[data.range.start + 1 .. data.range.end]) |arg| try tree.dumpNode(arg, level + delta, mapper, config, w);
const child_nodes = tree.childNodes(node);
for (child_nodes) |arg| {
try tree.dumpNode(arg, level + delta, mapper, config, w);
}
},
.builtin_call_expr_one => {
try w.writeByteNTimes(' ', level + half);
try w.writeAll("name: ");
try config.setColor(w, NAME);
try w.print("{s}\n", .{tree.tokSlice(data.decl.name)});
try config.setColor(w, .reset);
if (data.decl.node != .none) {
const child_nodes = tree.childNodes(node);
for (child_nodes) |arg| {
try w.writeByteNTimes(' ', level + half);
try w.writeAll("arg:\n");
try tree.dumpNode(data.decl.node, level + delta, mapper, config, w);
try tree.dumpNode(arg, level + delta, mapper, config, w);
}
},
.special_builtin_call_one => {
Expand Down

0 comments on commit 4445565

Please sign in to comment.