feature. See also
. The project being documented here (as the example) is the Zig library itself.
Walk.scanDecls
fn scanDecls(w: *Walk, namespace: *Scope.Namespace, members: []const Ast.Node.Index) Oom!void
File
Code
fn scanDecls(w: *Walk, namespace: *Scope.Namespace, members: []const Ast.Node.Index) Oom!void {
const ast = w.file.get_ast();
for (members) |member_node| {
const name_token = switch (ast.nodeTag(member_node)) {
.global_var_decl,
.local_var_decl,
.simple_var_decl,
.aligned_var_decl,
=> ast.nodeMainToken(member_node) + 1,
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
.fn_decl,
=> blk: {
const ident = ast.nodeMainToken(member_node) + 1;
if (ast.tokenTag(ident) != .identifier) continue;
break :blk ident;
},
.test_decl => {
const opt_ident_token = ast.nodeData(member_node).opt_token_and_node[0];
if (opt_ident_token.unwrap()) |ident_token| {
const is_doctest = ast.tokenTag(ident_token) == .identifier;
if (is_doctest) {
const token_bytes = ast.tokenSlice(ident_token);
try namespace.doctests.put(gpa, token_bytes, member_node);
}
}
continue;
},
else => continue,
};
const token_bytes = ast.tokenSlice(name_token);
try namespace.names.put(gpa, token_bytes, member_node);
}
}