zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ab2c602f3493d76e1ad6872cb578115b45b7c6fe (tree)
parent 23cf44c227678bde07b872e2a5ff1089c028c582
Author: Loris Cro <kappaloris@gmail.com>
Date:   Fri, 31 Mar 2023 17:26:55 +0200

Merge pull request #14823 from der-teufel-programming/autodoc-quickfixes

autodoc: Add struct to tryResolveRefPath
Diffstat:
Mlib/docs/main.js | 6+++---
Msrc/Autodoc.zig | 19+++++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/lib/docs/main.js b/lib/docs/main.js @@ -1139,9 +1139,9 @@ const NAV_MODES = { return exprName(switchIndex, opts); } case "fieldRef": { - const enumObj = exprName({ type: expr.fieldRef.type }, opts); - const field = - getAstNode(enumObj.src).fields[expr.fieldRef.index]; + const field_idx = expr.fieldRef.index; + const type = getType(expr.fieldRef.type); + const field = getAstNode(type.src).fields[field_idx]; const name = getAstNode(field).name; return name; } diff --git a/src/Autodoc.zig b/src/Autodoc.zig @@ -3616,6 +3616,25 @@ fn tryResolveRefPath( continue :outer; }, }, + .@"struct" => |st| { + for (st) |field| { + if (std.mem.eql(u8, field.name, child_string)) { + path[i + 1] = field.val.expr; + continue :outer; + } + } + + // if we got here, our search failed + printWithContext( + file, + inst_index, + "failed to match `{s}` in struct", + .{child_string}, + ); + + path[i + 1] = (try self.cteTodo("match failure")).expr; + continue :outer; + }, } }