Skip to content

Commit

Permalink
Resolve type of enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
FnControlOption committed Jul 10, 2023
1 parent e14c48f commit 8179303
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,11 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
.@"try",
.address_of,
=> {
if (node_tags[node].isContainerField()) {
const container_type = innermostContainer(handle, offsets.tokenToIndex(tree, tree.firstToken(node)));
if (container_type.isEnumType())
return container_type.instanceTypeVal();
}
const base = .{ .node = datas[node].lhs, .handle = handle };
const base_type = (try analyser.resolveTypeOfNodeInternal(base)) orelse
return null;
Expand Down
13 changes: 8 additions & 5 deletions src/features/hover.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ pub fn hoverSymbol(server: *Server, decl_handle: Analyser.DeclWithHandle, markup
} else if (tree.fullFnProto(&buf, node)) |fn_proto| {
break :def Analyser.getFunctionSignature(tree, fn_proto);
} else if (tree.fullContainerField(node)) |field| {
std.debug.assert(field.ast.type_expr != 0);
try server.analyser.referencedTypesFromNode(
.{ .node = field.ast.type_expr, .handle = handle },
&reference_collector,
);
var converted = field;
converted.convertToNonTupleLike(tree.nodes);

if (converted.ast.type_expr != 0)
try server.analyser.referencedTypesFromNode(
.{ .node = converted.ast.type_expr, .handle = handle },
&reference_collector,
);

break :def Analyser.getContainerFieldSignature(tree, field);
} else {
Expand Down

0 comments on commit 8179303

Please sign in to comment.