fix semantic tokens on if capture by ref
This commit is contained in:
parent
498517ba71
commit
d9965c7834
@ -516,8 +516,10 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
|||||||
try writeToken(builder, if_node.ast.if_token, .keyword);
|
try writeToken(builder, if_node.ast.if_token, .keyword);
|
||||||
try callWriteNodeTokens(allocator, .{ builder, if_node.ast.cond_expr });
|
try callWriteNodeTokens(allocator, .{ builder, if_node.ast.cond_expr });
|
||||||
|
|
||||||
if (if_node.payload_token) |payload| {
|
if (if_node.payload_token) |payload_token| {
|
||||||
try writeTokenMod(builder, payload, .variable, .{ .declaration = true });
|
const capture_is_ref = token_tags[payload_token] == .asterisk;
|
||||||
|
const actual_payload = payload_token + @boolToInt(capture_is_ref);
|
||||||
|
try writeTokenMod(builder, actual_payload, .variable, .{ .declaration = true });
|
||||||
}
|
}
|
||||||
try callWriteNodeTokens(allocator, .{ builder, if_node.ast.then_expr });
|
try callWriteNodeTokens(allocator, .{ builder, if_node.ast.then_expr });
|
||||||
|
|
||||||
|
@ -808,6 +808,16 @@ test "semantic tokens - if" {
|
|||||||
.{ "err", .variable, .{ .declaration = true } },
|
.{ "err", .variable, .{ .declaration = true } },
|
||||||
.{ "err", .variable, .{} },
|
.{ "err", .variable, .{} },
|
||||||
});
|
});
|
||||||
|
try testSemanticTokens(
|
||||||
|
\\const foo = if (null) |*value| {};
|
||||||
|
, &.{
|
||||||
|
.{ "const", .keyword, .{} },
|
||||||
|
.{ "foo", .variable, .{ .declaration = true } },
|
||||||
|
.{ "=", .operator, .{} },
|
||||||
|
.{ "if", .keyword, .{} },
|
||||||
|
.{ "null", .keywordLiteral, .{} },
|
||||||
|
.{ "value", .variable, .{ .declaration = true } },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
test "semantic tokens - while" {
|
test "semantic tokens - while" {
|
||||||
|
Loading…
Reference in New Issue
Block a user