test and simplify semantic tokens on function call
This commit is contained in:
parent
3fefcfb398
commit
ae5fa110b5
@ -44,7 +44,6 @@ const Builder = struct {
|
||||
analyser: *Analyser,
|
||||
handle: *const DocumentStore.Handle,
|
||||
previous_source_index: usize = 0,
|
||||
previous_token: ?Ast.TokenIndex = null,
|
||||
token_buffer: std.ArrayListUnmanaged(u32) = .{},
|
||||
encoding: offsets.Encoding,
|
||||
limited: bool,
|
||||
@ -595,11 +594,6 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
||||
try writeToken(builder, call.async_token, .keyword);
|
||||
try callWriteNodeTokens(allocator, .{ builder, call.ast.fn_expr });
|
||||
|
||||
if (builder.previous_token) |prev| {
|
||||
if (prev != ast.lastToken(tree, call.ast.fn_expr) and token_tags[ast.lastToken(tree, call.ast.fn_expr)] == .identifier) {
|
||||
try writeToken(builder, ast.lastToken(tree, call.ast.fn_expr), .function);
|
||||
}
|
||||
}
|
||||
for (call.ast.params) |param| try callWriteNodeTokens(allocator, .{ builder, param });
|
||||
},
|
||||
.slice,
|
||||
|
@ -226,6 +226,42 @@ test "semantic tokens - field access" {
|
||||
});
|
||||
}
|
||||
|
||||
test "semantic tokens - call" {
|
||||
try testSemanticTokens(
|
||||
\\fn foo() void {}
|
||||
\\const alpha = foo();
|
||||
, &.{
|
||||
.{ "fn", .keyword, .{} },
|
||||
.{ "foo", .function, .{ .declaration = true } },
|
||||
.{ "void", .type, .{} },
|
||||
|
||||
.{ "const", .keyword, .{} },
|
||||
.{ "alpha", .variable, .{ .declaration = true } },
|
||||
.{ "=", .operator, .{} },
|
||||
.{ "foo", .function, .{} },
|
||||
});
|
||||
try testSemanticTokens(
|
||||
\\const ns = struct {
|
||||
\\ fn foo() void {}
|
||||
\\};
|
||||
\\const alpha = ns.foo();
|
||||
, &.{
|
||||
.{ "const", .keyword, .{} },
|
||||
.{ "ns", .type, .{ .namespace = true, .declaration = true } },
|
||||
.{ "=", .operator, .{} },
|
||||
.{ "struct", .keyword, .{} },
|
||||
.{ "fn", .keyword, .{} },
|
||||
.{ "foo", .function, .{ .declaration = true } },
|
||||
.{ "void", .type, .{} },
|
||||
|
||||
.{ "const", .keyword, .{} },
|
||||
.{ "alpha", .variable, .{ .declaration = true } },
|
||||
.{ "=", .operator, .{} },
|
||||
.{ "ns", .type, .{ .namespace = true } },
|
||||
.{ "foo", .function, .{} },
|
||||
});
|
||||
}
|
||||
|
||||
test "semantic tokens - catch" {
|
||||
try testSemanticTokens(
|
||||
\\var alpha = a catch b;
|
||||
|
Loading…
Reference in New Issue
Block a user