authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-03-31 17:26:55+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-03-31 17:26:55+02:00
logab2c602f3493d76e1ad6872cb578115b45b7c6fe
tree7249d0c87f7862fcc9896af0d1897bad39da46a1
parent23cf44c227678bde07b872e2a5ff1089c028c582
parent27d2848e0096d31cb42cb258a89ed276ec26434e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

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

autodoc: Add struct to tryResolveRefPath

2 files changed, 22 insertions(+), 3 deletions(-)

lib/docs/main.js+3-3
...@@ -1139,9 +1139,9 @@ const NAV_MODES = {...@@ -1139,9 +1139,9 @@ const NAV_MODES = {
1139 return exprName(switchIndex, opts);1139 return exprName(switchIndex, opts);
1140 }1140 }
1141 case "fieldRef": {1141 case "fieldRef": {
1142 const enumObj = exprName({ type: expr.fieldRef.type }, opts);1142 const field_idx = expr.fieldRef.index;
1143 const field =1143 const type = getType(expr.fieldRef.type);
1144 getAstNode(enumObj.src).fields[expr.fieldRef.index];1144 const field = getAstNode(type.src).fields[field_idx];
1145 const name = getAstNode(field).name;1145 const name = getAstNode(field).name;
1146 return name;1146 return name;
1147 }1147 }
src/Autodoc.zig+19
...@@ -3616,6 +3616,25 @@ fn tryResolveRefPath(...@@ -3616,6 +3616,25 @@ fn tryResolveRefPath(
3616 continue :outer;3616 continue :outer;
3617 },3617 },
3618 },3618 },
3619 .@"struct" => |st| {
3620 for (st) |field| {
3621 if (std.mem.eql(u8, field.name, child_string)) {
3622 path[i + 1] = field.val.expr;
3623 continue :outer;
3624 }
3625 }
3626
3627 // if we got here, our search failed
3628 printWithContext(
3629 file,
3630 inst_index,
3631 "failed to match `{s}` in struct",
3632 .{child_string},
3633 );
3634
3635 path[i + 1] = (try self.cteTodo("match failure")).expr;
3636 continue :outer;
3637 },
3619 }3638 }
3620 }3639 }
36213640