Fixed slice access type resolution
This commit is contained in:
parent
8ddd80b788
commit
e7a1f5c34f
@ -466,46 +466,35 @@ fn resolveBracketAccessType(
|
|||||||
else => return null,
|
else => return null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lhs_node.cast(ast.Node.SimplePrefixOp)) |pop| {
|
if (lhs_node.castTag(.SliceType)) |slice_type| {
|
||||||
switch (lhs_node.tag) {
|
|
||||||
.SliceType => {
|
|
||||||
if (rhs == .Single)
|
if (rhs == .Single)
|
||||||
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||||
.node = pop.rhs,
|
.node = slice_type.rhs,
|
||||||
.handle = lhs.handle,
|
.handle = lhs.handle,
|
||||||
}, bound_type_params)) orelse return null).instanceTypeVal();
|
}, bound_type_params)) orelse return null).instanceTypeVal();
|
||||||
return lhs;
|
return lhs;
|
||||||
},
|
} else if (lhs_node.castTag(.ArrayType)) |array_type| {
|
||||||
.ArrayType => {
|
|
||||||
if (rhs == .Single)
|
if (rhs == .Single)
|
||||||
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||||
.node = pop.rhs,
|
.node = array_type.rhs,
|
||||||
.handle = lhs.handle,
|
.handle = lhs.handle,
|
||||||
}, bound_type_params)) orelse return null).instanceTypeVal();
|
}, bound_type_params)) orelse return null).instanceTypeVal();
|
||||||
return TypeWithHandle{
|
return TypeWithHandle{
|
||||||
.type = .{ .data = .{ .slice = pop.rhs }, .is_type_val = false },
|
.type = .{ .data = .{ .slice = array_type.rhs }, .is_type_val = false },
|
||||||
.handle = lhs.handle,
|
.handle = lhs.handle,
|
||||||
};
|
};
|
||||||
},
|
} else if (lhs_node.castTag(.PtrType)) |ptr_type| {
|
||||||
.PtrType => {
|
if (ptr_type.rhs.castTag(.ArrayType)) |child_arr| {
|
||||||
if (pop.rhs.cast(ast.Node.SimplePrefixOp)) |child_pop| {
|
|
||||||
switch (pop.rhs.tag) {
|
|
||||||
.ArrayType => {
|
|
||||||
if (rhs == .Single) {
|
if (rhs == .Single) {
|
||||||
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||||
.node = child_pop.rhs,
|
.node = child_arr.rhs,
|
||||||
.handle = lhs.handle,
|
.handle = lhs.handle,
|
||||||
}, bound_type_params)) orelse return null).instanceTypeVal();
|
}, bound_type_params)) orelse return null).instanceTypeVal();
|
||||||
}
|
}
|
||||||
return lhs;
|
return lhs;
|
||||||
},
|
|
||||||
else => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
else => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/main.zig
12
src/main.zig
@ -451,18 +451,6 @@ fn nodeToCompletion(
|
|||||||
.kind = .Field,
|
.kind = .Field,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.ContainerDecl => {
|
|
||||||
log(std.log.Level.debug, .cont, "Unhandled container decl", .{});
|
|
||||||
const container = node.castTag(.ContainerDecl).?;
|
|
||||||
for (container.fieldsAndDecls()) |snode|
|
|
||||||
if (snode.castTag(.ContainerField)) |field|
|
|
||||||
try list.append(.{
|
|
||||||
.label = handle.tree.tokenSlice(field.name_token),
|
|
||||||
.kind = .Field,
|
|
||||||
.documentation = doc,
|
|
||||||
.detail = analysis.getContainerFieldSignature(handle.tree, field),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
else => if (analysis.nodeToString(handle.tree, node)) |string| {
|
else => if (analysis.nodeToString(handle.tree, node)) |string| {
|
||||||
try list.append(.{
|
try list.append(.{
|
||||||
.label = string,
|
.label = string,
|
||||||
|
Loading…
Reference in New Issue
Block a user