Use declaration modifier instead of definition

This commit is contained in:
GrayJack 2021-01-16 03:33:35 -03:00
parent 2a968f51d7
commit 4f5af38031
No known key found for this signature in database
GPG Key ID: AF36C790809AA487

View File

@ -28,6 +28,7 @@ pub const TokenModifiers = packed struct {
@"enum": bool = false,
@"union": bool = false,
@"opaque": bool = false,
declaration: bool = false,
definition: bool = false,
@"async": bool = false,
documentation: bool = false,
@ -291,9 +292,9 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D
try writeToken(builder, var_decl.getComptimeToken(), .keyword);
try writeToken(builder, var_decl.mut_token, .keyword);
if (try analysis.resolveTypeOfNode(store, arena, .{ .node = node, .handle = handle })) |decl_type| {
try colorIdentifierBasedOnType(builder, decl_type, var_decl.name_token, .{ .definition = true });
try colorIdentifierBasedOnType(builder, decl_type, var_decl.name_token, .{ .declaration = true });
} else {
try writeTokenMod(builder, var_decl.name_token, .variable, .{ .definition = true });
try writeTokenMod(builder, var_decl.name_token, .variable, .{ .declaration = true });
}
try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, var_decl.getTypeNode() });
try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, var_decl.getAlignNode() });
@ -385,7 +386,7 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D
if (param_decl.doc_comments) |docs| try writeDocComments(builder, handle.tree, docs);
try writeToken(builder, param_decl.noalias_token, .keyword);
try writeToken(builder, param_decl.comptime_token, .keyword);
try writeTokenMod(builder, param_decl.name_token, .parameter, .{ .definition = true });
try writeTokenMod(builder, param_decl.name_token, .parameter, .{ .declaration = true });
switch (param_decl.param_type) {
.any_type => |var_node| try writeToken(builder, var_node.firstToken(), .type),
.type_expr => |type_expr| try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, type_expr }),