autodoc: Add struct to tryResolveRefPath

fix rendering of fieldRef in exprName
This commit is contained in:
Krzysztof Wolicki Der Teufel 2023-03-07 00:22:48 +01:00
parent 6218e40046
commit 27d2848e00
2 changed files with 22 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
},
}
}