replace semantic token type .field with .property
This commit is contained in:
parent
6836f9361d
commit
498517ba71
@ -13,7 +13,7 @@ pub const TokenType = enum(u32) {
|
|||||||
parameter,
|
parameter,
|
||||||
variable,
|
variable,
|
||||||
enumMember,
|
enumMember,
|
||||||
field,
|
property,
|
||||||
errorTag,
|
errorTag,
|
||||||
function,
|
function,
|
||||||
keyword,
|
keyword,
|
||||||
@ -115,7 +115,7 @@ const Builder = struct {
|
|||||||
.parameter,
|
.parameter,
|
||||||
.variable,
|
.variable,
|
||||||
.enumMember,
|
.enumMember,
|
||||||
.field,
|
.property,
|
||||||
.errorTag,
|
.errorTag,
|
||||||
.function,
|
.function,
|
||||||
.label,
|
.label,
|
||||||
@ -162,8 +162,9 @@ fn fieldTokenType(container_decl: Ast.Node.Index, handle: *const DocumentStore.H
|
|||||||
const main_token = handle.tree.nodes.items(.main_token)[container_decl];
|
const main_token = handle.tree.nodes.items(.main_token)[container_decl];
|
||||||
if (main_token > handle.tree.tokens.len) return null;
|
if (main_token > handle.tree.tokens.len) return null;
|
||||||
return @as(?TokenType, switch (handle.tree.tokens.items(.tag)[main_token]) {
|
return @as(?TokenType, switch (handle.tree.tokens.items(.tag)[main_token]) {
|
||||||
.keyword_struct => .field,
|
.keyword_struct => .property,
|
||||||
.keyword_union, .keyword_enum => .enumMember,
|
.keyword_union, .keyword_enum => .enumMember,
|
||||||
|
.keyword_error => .errorTag,
|
||||||
else => null,
|
else => null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -229,7 +230,7 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
|||||||
.container_field,
|
.container_field,
|
||||||
.container_field_align,
|
.container_field_align,
|
||||||
.container_field_init,
|
.container_field_init,
|
||||||
=> try writeContainerField(builder, node, .field),
|
=> try writeContainerField(builder, node, .property),
|
||||||
.@"errdefer" => {
|
.@"errdefer" => {
|
||||||
try writeToken(builder, main_token, .keyword);
|
try writeToken(builder, main_token, .keyword);
|
||||||
|
|
||||||
@ -253,7 +254,7 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
|||||||
|
|
||||||
for (statements) |child| {
|
for (statements) |child| {
|
||||||
if (node_tags[child].isContainerField()) {
|
if (node_tags[child].isContainerField()) {
|
||||||
try writeContainerField(builder, child, .field);
|
try writeContainerField(builder, child, .property);
|
||||||
} else {
|
} else {
|
||||||
try callWriteNodeTokens(allocator, .{ builder, child });
|
try callWriteNodeTokens(allocator, .{ builder, child });
|
||||||
}
|
}
|
||||||
@ -573,8 +574,8 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
|||||||
|
|
||||||
for (struct_init.ast.fields) |field_init| {
|
for (struct_init.ast.fields) |field_init| {
|
||||||
const init_token = tree.firstToken(field_init);
|
const init_token = tree.firstToken(field_init);
|
||||||
try writeToken(builder, init_token - 3, field_token_type orelse .field); // '.'
|
try writeToken(builder, init_token - 3, field_token_type orelse .property); // '.'
|
||||||
try writeToken(builder, init_token - 2, field_token_type orelse .field); // name
|
try writeToken(builder, init_token - 2, field_token_type orelse .property); // name
|
||||||
try writeToken(builder, init_token - 1, .operator); // '='
|
try writeToken(builder, init_token - 1, .operator); // '='
|
||||||
try callWriteNodeTokens(allocator, .{ builder, field_init });
|
try callWriteNodeTokens(allocator, .{ builder, field_init });
|
||||||
}
|
}
|
||||||
@ -823,7 +824,7 @@ fn writeNodeTokens(builder: *Builder, node: Ast.Node.Index) error{OutOfMemory}!v
|
|||||||
const tok_type: ?TokenType = if (ast.isContainer(lhs_type.handle.tree, left_type_node))
|
const tok_type: ?TokenType = if (ast.isContainer(lhs_type.handle.tree, left_type_node))
|
||||||
fieldTokenType(decl_node, lhs_type.handle)
|
fieldTokenType(decl_node, lhs_type.handle)
|
||||||
else if (left_type_node == 0)
|
else if (left_type_node == 0)
|
||||||
TokenType.field
|
.property
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
@ -516,9 +516,9 @@ test "semantic tokens - struct" {
|
|||||||
.{ "Foo", .type, .{ .@"struct" = true, .declaration = true } },
|
.{ "Foo", .type, .{ .@"struct" = true, .declaration = true } },
|
||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "struct", .keyword, .{} },
|
.{ "struct", .keyword, .{} },
|
||||||
.{ "alpha", .field, .{} },
|
.{ "alpha", .property, .{} },
|
||||||
.{ "u32", .type, .{} },
|
.{ "u32", .type, .{} },
|
||||||
.{ "beta", .field, .{} },
|
.{ "beta", .property, .{} },
|
||||||
.{ "void", .type, .{} },
|
.{ "void", .type, .{} },
|
||||||
});
|
});
|
||||||
try testSemanticTokens(
|
try testSemanticTokens(
|
||||||
@ -531,12 +531,12 @@ test "semantic tokens - struct" {
|
|||||||
.{ "Foo", .type, .{ .@"struct" = true, .declaration = true } },
|
.{ "Foo", .type, .{ .@"struct" = true, .declaration = true } },
|
||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "struct", .keyword, .{} },
|
.{ "struct", .keyword, .{} },
|
||||||
.{ "alpha", .field, .{} },
|
.{ "alpha", .property, .{} },
|
||||||
.{ "u32", .type, .{} },
|
.{ "u32", .type, .{} },
|
||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "3", .number, .{} },
|
.{ "3", .number, .{} },
|
||||||
.{ "comptime", .keyword, .{} },
|
.{ "comptime", .keyword, .{} },
|
||||||
.{ "beta", .field, .{} },
|
.{ "beta", .property, .{} },
|
||||||
.{ "void", .type, .{} },
|
.{ "void", .type, .{} },
|
||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
});
|
});
|
||||||
@ -592,7 +592,7 @@ test "semantic tokens - union" {
|
|||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "union", .keyword, .{} },
|
.{ "union", .keyword, .{} },
|
||||||
.{ "E", .variable, .{} },
|
.{ "E", .variable, .{} },
|
||||||
.{ "alpha", .field, .{} },
|
.{ "alpha", .property, .{} },
|
||||||
});
|
});
|
||||||
try testSemanticTokens(
|
try testSemanticTokens(
|
||||||
\\const Foo = union(E) {
|
\\const Foo = union(E) {
|
||||||
@ -605,8 +605,8 @@ test "semantic tokens - union" {
|
|||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "union", .keyword, .{} },
|
.{ "union", .keyword, .{} },
|
||||||
.{ "E", .variable, .{} },
|
.{ "E", .variable, .{} },
|
||||||
.{ "alpha", .field, .{} },
|
.{ "alpha", .property, .{} },
|
||||||
.{ "beta", .field, .{} },
|
.{ "beta", .property, .{} },
|
||||||
.{ "void", .keyword, .{} },
|
.{ "void", .keyword, .{} },
|
||||||
});
|
});
|
||||||
try testSemanticTokens(
|
try testSemanticTokens(
|
||||||
@ -619,7 +619,7 @@ test "semantic tokens - union" {
|
|||||||
.{ "=", .operator, .{} },
|
.{ "=", .operator, .{} },
|
||||||
.{ "union", .keyword, .{} },
|
.{ "union", .keyword, .{} },
|
||||||
.{ "E", .variable, .{} },
|
.{ "E", .variable, .{} },
|
||||||
.{ "alpha", .field, .{} },
|
.{ "alpha", .property, .{} },
|
||||||
.{ "void", .keyword, .{} },
|
.{ "void", .keyword, .{} },
|
||||||
.{ "align", .keyword, .{} },
|
.{ "align", .keyword, .{} },
|
||||||
.{ "2", .number, .{} },
|
.{ "2", .number, .{} },
|
||||||
|
Loading…
Reference in New Issue
Block a user