diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index debe16cca..5c54fdde4 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -55,8 +55,10 @@ "patterns": [ { "include": "#attribute" }, { "include": "#procedure-assignment" }, + { "include": "#enum-assignment" }, { "include": "#type-assignment" }, { "include": "#distinct-type-assignment" }, + { "include": "#for-in-assignment" }, { "include": "#constant-assignment" }, { "include": "#variable-assignment" }, { "include": "#case-clause" }, @@ -69,8 +71,10 @@ "assignments": { "patterns": [ { "include": "#procedure-assignment" }, + { "include": "#enum-assignment" }, { "include": "#type-assignment" }, { "include": "#distinct-type-assignment" }, + { "include": "#for-in-assignment" }, { "include": "#constant-assignment" }, { "include": "#variable-assignment" }, { "include": "#type-annotation" } @@ -115,8 +119,8 @@ "match": "\\b([A-Za-z_]\\w*)\\b", "name": "entity.other.attribute-name.odin" }, { - "match": ",", - "name": "punctuation.odin" + "name": "punctuation.odin", + "match": "," },{ "begin": "=", "beginCaptures": {"0": {"name": "keyword.operator.assignment.odin"}}, @@ -127,11 +131,13 @@ }, "procedure-assignment": { "name": "meta.definition.variable.odin", - "begin": "\\b([A-Za-z_]\\w*)\\s*(:\\s*:|=)\\s*(#\\w+)?\\s*(?=proc\\b)", + "begin": "\\b([A-Za-z_]\\w*)\\s*(:)\\s*\\w*\\s*(:|=)\\s*(?:(#)(\\w+))?\\s*(?=proc\\b)", "beginCaptures": { "1": { "name": "meta.definition.function.odin entity.name.function.odin" }, - "2": { "name": "keyword.operator.assignment.odin" }, - "3": { "name": "keyword.other.odin" } + "2": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, + "3": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, + "4": { "name": "keyword.control.directive.odin" }, + "5": { "name": "entity.other.directive-name.odin" } }, "end": "(?=^)|(?<=\\})", "patterns": [ { "include": "#type-declaration" } ] @@ -140,8 +146,8 @@ "name": "meta.definition.variable.odin", "begin": "\\b([A-Za-z_]\\w*)\\s*(:\\s*:)\\s*(?=(struct|union|enum|bit_set|bit_field)\\b)", "beginCaptures": { - "1": { "name": "entity.name.type.odin" }, - "2": { "name": "keyword.operator.assignment.odin" }, + "1": { "name": "entity.name.type.odin entity.name.constant.odin" }, + "2": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, "3": { "name": "storage.type.odin" } }, "end": "(?=^)|(?<=\\})", @@ -151,8 +157,8 @@ "name": "meta.definition.variable.odin", "begin": "\\b([A-Za-z_]\\w*)\\s*(:\\s*:)\\s*(?=(distinct)\\b)", "beginCaptures": { - "1": { "name": "entity.name.type.odin" }, - "2": { "name": "keyword.operator.assignment.odin" }, + "1": { "name": "entity.name.type.odin entity.name.constant.odin" }, + "2": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, "3": { "name": "storage.type.odin" } }, "end": "(?=^)|(?<=\\})", @@ -162,32 +168,57 @@ "name": "meta.definition.variable.odin", "match": "([A-Za-z_]\\w*)\\s*(:\\s*:)", "captures": { - "1": { "name": "variable.other.constant.odin" }, - "2": { "name": "keyword.operator.assignment.odin" } + "1": { "name": "variable.other.constant.odin entity.name.constant.odin" }, + "2": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" } + } + }, + "for-in-assignment": { + "name": "meta.definition.for-in.odin", + "match": "for\\s+(?:(\\&)?([A-Za-z_]\\w*)\\s*(,)\\s*)?(\\&)?([A-Za-z_]\\w*)\\s*(in)\\b", + "captures": { + "1": { "name": "punctuation.odin" }, + "2": { "name": "variable.name.odin entity.name.variable.odin" }, + "3": { "name": "punctuation.odin" }, + "4": { "name": "punctuation.odin" }, + "5": { "name": "variable.name.odin entity.name.variable.odin" }, + "6": { "name": "keyword.control.odin" } } }, "variable-assignment": { "name": "meta.definition.variable.odin", "match": "(?:([A-Za-z_]\\w*)\\s*(,)\\s*)?(?:([A-Za-z_]\\w*)\\s*(,)\\s*)?([A-Za-z_]\\w*)\\s*(:\\s*=)", "captures": { - "1": { "name": "variable.name.odin" }, + "1": { "name": "variable.name.odin entity.name.variable.odin" }, "2": { "name": "punctuation.odin" }, - "3": { "name": "variable.name.odin" }, + "3": { "name": "variable.name.odin entity.name.variable.odin" }, "4": { "name": "punctuation.odin" }, - "5": { "name": "variable.name.odin" }, - "6": { "name": "keyword.operator.assignment.odin" } + "5": { "name": "variable.name.odin entity.name.variable.odin" }, + "6": { "name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" } } }, + "enum-assignment": { + "name": "meta.definition.enum.odin", + "begin": "([A-Za-z_]\\w*)\\s*:\\s*:\\s*(enum)\\s*(?=\\w*\\s*\\{)", + "beginCaptures": { + "1": { "name": "entity.name.enum.odin" }, + "2": { "name": "keyword.enum.odin" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.block.odin" } + }, + "patterns": [ { "include": "#statements" } ] + }, "type-annotation": { "name": "meta.type.annotation.odin", "begin": "(?:([A-Za-z_]\\w*)\\s*(,)\\s*)?(?:([A-Za-z_]\\w*)\\s*(,)\\s*)?([A-Za-z_]\\w*)\\s*(:)", "beginCaptures": { - "1": { "name": "variable.name.odin" }, + "1": { "name": "variable.name.odin entity.name.variable.odin" }, "2": { "name": "punctuation.odin" }, - "3": { "name": "variable.name.odin" }, + "3": { "name": "variable.name.odin entity.name.variable.odin" }, "4": { "name": "punctuation.odin" }, - "5": { "name": "variable.name.odin" }, - "6": { "name": "keyword.operator.type.annotation.odin" } + "5": { "name": "variable.name.odin entity.name.variable.odin" }, + "6": { "name": "keyword.operator.type.annotation.odin keyword.operator.declaration.odin" } }, "end": "(?=^|,|;|\\)|=|:|for|switch|if|{)", "patterns": [ { "include": "#type-declaration" } ] @@ -451,7 +482,11 @@ }, { "name": "keyword.control.odin", - "match": "\\b(if|else|or_else|when|where|for|in|not_in|defer|switch|return|or_return)\\b" + "match": "\\b(if|else|or_else|when|where|for|in|not_in|defer|switch)\\b" + }, + { + "name": "keyword.control.odin keyword.control.jumpy.odin", + "match": "\\b(return|or_return)\\b" }, { "match": "\\b(break|or_break|continue|or_continue)\\b\\s*(\\w+)?", @@ -506,11 +541,13 @@ }, { "name": "keyword.operator.assignment.compound.odin", - "match": "[+\\-*/%]=|%%=" + "match": "([+\\-*/%]%?)=", + "captures": {"1": {"name": "keyword.operator.in-compound" }} }, { "name": "keyword.operator.assignment.compound.bitwise.odin", - "match": "\\|=|~=|&~?=|<<=|>>=" + "match": "(\\||~|&~?|<<|>>)=", + "captures": {"1": {"name": "keyword.operator.in-compound" }} }, { "name": "keyword.operator.comparison.odin", @@ -530,7 +567,12 @@ }, { "name": "keyword.operator.assignment.odin", - "match": ":[:=]|=" + "match": "(:)=|(::)|(=)", + "captures": { + "1": {"name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, + "2": {"name": "keyword.operator.assignment.odin keyword.operator.declaration.odin" }, + "3": {"name": "keyword.operator.assignment.odin" } + } }, { "name": "keyword.operator.address.odin", @@ -550,7 +592,11 @@ }, { "name": "entity.name.tag.odin", - "match": "#[A-Za-z_]\\w*" + "match": "(#)([A-Za-z_]\\w*)", + "captures": { + "1": { "name": "keyword.control.directive.odin" }, + "2": { "name": "entity.other.directive-name.odin" } + } } ] }, diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin index 38f193a1a..7cd899dfb 100644 --- a/src/server/semantic_tokens.odin +++ b/src/server/semantic_tokens.odin @@ -6,6 +6,7 @@ https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/spe */ package server +import "core:log" import "core:odin/ast" import "core:odin/tokenizer" import "core:unicode/utf8" @@ -245,7 +246,7 @@ visit_node :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder) { visit_node(n.row_index, builder) visit_node(n.column_index, builder) case ^ast.Poly_Type: - write_semantic_node(builder, n.type, .TypeParameter) + write_semantic_node(builder, n.type, .TypeParameter, {.Declaration}) visit_node(n.specialization, builder) case ^ast.Range_Stmt: for val in n.vals { @@ -403,6 +404,7 @@ visit_node :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder) { visit_value_decl :: proc(value_decl: ast.Value_Decl, builder: ^SemanticTokenBuilder) { modifiers: SemanticTokenModifiers = value_decl.is_mutable ? {} : {.ReadOnly} + modifiers += {.Declaration} for name in value_decl.names { ident := name.derived.(^ast.Ident) or_continue @@ -425,7 +427,7 @@ visit_proc_type :: proc(node: ^ast.Proc_Type, builder: ^SemanticTokenBuilder) { for param in node.params.list { for name in param.names { if ident, ok := name.derived.(^ast.Ident); ok { - write_semantic_node(builder, name, .Parameter) + write_semantic_node(builder, name, .Parameter, {.Declaration}) } } @@ -436,7 +438,9 @@ visit_proc_type :: proc(node: ^ast.Proc_Type, builder: ^SemanticTokenBuilder) { if node.results != nil { for result in node.results.list { - visit_nodes(result.names, builder) + for name in result.names { + write_semantic_node(builder, name, .Variable, {.Declaration}) + } visit_node(result.type, builder) } } @@ -467,7 +471,7 @@ visit_struct_fields :: proc(node: ast.Struct_Type, builder: ^SemanticTokenBuilde for field in node.fields.list { for name in field.names { if ident, ok := name.derived.(^ast.Ident); ok { - write_semantic_node(builder, ident, .Property) + write_semantic_node(builder, ident, .Property, {.Declaration}) } } @@ -483,7 +487,7 @@ visit_poly_params :: proc(params: ^ast.Field_List, builder: ^SemanticTokenBuilde for param in params.list { for name in param.names { if poly, ok := name.derived.(^ast.Poly_Type); ok { - write_semantic_node(builder, poly.type, .TypeParameter) + write_semantic_node(builder, poly.type, .TypeParameter, {.Declaration}) } } visit_node(param.type, builder) diff --git a/src/testing/testing.odin b/src/testing/testing.odin index f7c56acd4..3b8dfe8d4 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -704,7 +704,7 @@ expect_action_with_edit :: proc(t: ^testing.T, src: ^Source, action_name: string log.errorf("Action '%s' not found in actions: %v", action_name, actions) } -expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.SemanticToken) { +expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.SemanticToken, loc := #caller_location) { setup(src) defer teardown(src) @@ -723,6 +723,7 @@ expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.S "\nExpected %d tokens, but received %d", len(expected), len(tokens), + loc=loc, ) for i in 0 ..< min(len(expected), len(tokens)) { @@ -742,6 +743,7 @@ expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.S a.len, a.type, a.modifiers, + loc=loc, ) } } diff --git a/tests/semantic_tokens_test.odin b/tests/semantic_tokens_test.odin index a9449f219..aca0e879c 100644 --- a/tests/semantic_tokens_test.odin +++ b/tests/semantic_tokens_test.odin @@ -19,16 +19,16 @@ my_function :: proc() { } test.expect_semantic_tokens(t, &src, { - {1, 0, 9, .Type, {.ReadOnly}}, // [0] Proc_Type - {0, 18, 1, .Parameter, {}}, // [1] a - {0, 3, 6, .Type, {.ReadOnly}}, // [2] string - {0, 11, 3, .Type, {.ReadOnly}}, // [3] int - {1, 0, 11, .Function, {.ReadOnly}}, // [4] my_function - {1, 1, 1, .Variable, {}}, // [5] a - {1, 1, 1, .Variable, {}}, // [6] b - {0, 5, 1, .Variable, {}}, // [7] a - {1, 1, 1, .Variable, {}}, // [8] c - {0, 9, 1, .Variable, {}}, // [9] b + {1, 0, 9, .Type, {.ReadOnly, .Declaration}}, // [0] Proc_Type + {0, 18, 1, .Parameter, {.Declaration}}, // [1] a + {0, 3, 6, .Type, {.ReadOnly}}, // [2] string + {0, 11, 3, .Type, {.ReadOnly}}, // [3] int + {1, 0, 11, .Function, {.ReadOnly, .Declaration}}, // [4] my_function + {1, 1, 1, .Variable, {.Declaration}}, // [5] a + {1, 1, 1, .Variable, {.Declaration}}, // [6] b + {0, 5, 1, .Variable, {}}, // [7] a + {1, 1, 1, .Variable, {.Declaration}}, // [8] c + {0, 9, 1, .Variable, {}}, // [9] b }) } @@ -43,12 +43,12 @@ semantic_tokens_global_consts :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Type, {.ReadOnly}}, // [0] Foo - {0, 10, 3, .Type, {.ReadOnly}}, // [1] f32 - {1, 2, 4, .Variable, {.ReadOnly}}, // [2] Foo2 - {0, 11, 3, .Type, {.ReadOnly}}, // [3] f32 - {1, 2, 4, .Type, {.ReadOnly}}, // [4] Foo3 - {0, 8, 3, .Type, {.ReadOnly}}, // [5] Foo + {1, 2, 3, .Type, {.ReadOnly, .Declaration}}, // [0] Foo + {0, 10, 3, .Type, {.ReadOnly}}, // [1] f32 + {1, 2, 4, .Variable, {.ReadOnly, .Declaration}}, // [2] Foo2 + {0, 11, 3, .Type, {.ReadOnly}}, // [3] f32 + {1, 2, 4, .Type, {.ReadOnly, .Declaration}}, // [4] Foo3 + {0, 8, 3, .Type, {.ReadOnly}}, // [5] Foo }) } @@ -64,13 +64,13 @@ semantic_tokens_literals_with_explicit_types :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Variable, {.ReadOnly}}, // [0] Foo - {1, 2, 4, .Variable, {.ReadOnly}}, // [1] Foo2 - {0, 7, 3, .Type, {.ReadOnly}}, // [2] int - {1, 2, 4, .Variable, {.ReadOnly}}, // [3] Foo3 - {0, 13, 6, .Type, {.ReadOnly}}, // [4] string - {1, 2, 4, .Variable, {.ReadOnly}}, // [5] Foo4 - {0, 8, 7, .Type, {.ReadOnly}}, // [6] cstring + {1, 2, 3, .Variable, {.ReadOnly, .Declaration}}, // [0] Foo + {1, 2, 4, .Variable, {.ReadOnly, .Declaration}}, // [1] Foo2 + {0, 7, 3, .Type, {.ReadOnly}}, // [2] int + {1, 2, 4, .Variable, {.ReadOnly, .Declaration}}, // [3] Foo3 + {0, 13, 6, .Type, {.ReadOnly}}, // [4] string + {1, 2, 4, .Variable, {.ReadOnly, .Declaration}}, // [5] Foo4 + {0, 8, 7, .Type, {.ReadOnly}}, // [6] cstring }) } @@ -90,14 +90,14 @@ semantic_tokens_struct_fields :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Struct, {.ReadOnly}}, // [0] Foo - {1, 3, 3, .Property, {}}, // [1] bar - {0, 5, 3, .Type, {.ReadOnly}}, // [2] int - {3, 2, 4, .Function, {.ReadOnly}}, // [3] main - {1, 3, 3, .Variable, {}}, // [4] foo - {0, 5, 3, .Struct, {.ReadOnly}}, // [5] Foo - {1, 3, 3, .Variable, {}}, // [6] foo - {0, 4, 3, .Property, {}}, // [7] bar + {1, 2, 3, .Struct, {.ReadOnly, .Declaration}}, // [0] Foo + {1, 3, 3, .Property, {.Declaration}}, // [1] bar + {0, 5, 3, .Type, {.ReadOnly}}, // [2] int + {3, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [3] main + {1, 3, 3, .Variable, {.Declaration}}, // [4] foo + {0, 5, 3, .Struct, {.ReadOnly}}, // [5] Foo + {1, 3, 3, .Variable, {}}, // [6] foo + {0, 4, 3, .Property, {}}, // [7] bar }) } @@ -113,10 +113,10 @@ semantic_tokens_proc_return :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Function, {.ReadOnly}}, // [0] foo - {0, 18, 3, .Variable, {}}, // [1] ret - {0, 5, 3, .Type, {.ReadOnly}}, // [2] int - {1, 3, 3, .Variable, {}}, // [3] ret + {1, 2, 3, .Function, {.ReadOnly, .Declaration}}, // [0] foo + {0, 18, 3, .Variable, {.Declaration}}, // [1] ret + {0, 5, 3, .Type, {.ReadOnly}}, // [2] int + {1, 3, 3, .Variable, {}}, // [3] ret }) } @@ -132,12 +132,12 @@ semantic_tokens_fixed_array_fields :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 4, .Function, {.ReadOnly}}, // [0] main - {1, 3, 3, .Variable, {}}, // [1] foo - {0, 8, 3, .Type, {.ReadOnly}}, // [2] f32 - {1, 3, 1, .Variable, {}}, // [3] y - {0, 5, 3, .Variable, {}}, // [4] foo - {0, 4, 1, .Property, {}}, // [5] x + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [0] main + {1, 3, 3, .Variable, {.Declaration}}, // [1] foo + {0, 8, 3, .Type, {.ReadOnly}}, // [2] f32 + {1, 3, 1, .Variable, {.Declaration}}, // [3] y + {0, 5, 3, .Variable, {}}, // [4] foo + {0, 4, 1, .Property, {}}, // [5] x }) } @@ -155,13 +155,13 @@ semantic_tokens_enum_member_default_param :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Enum, {.ReadOnly}}, // [0] Foo - {1, 3, 1, .EnumMember, {}}, // [1] A - {1, 3, 1, .EnumMember, {}}, // [2] B - {3, 2, 3, .Function, {.ReadOnly}}, // [3] bar - {0, 12, 3, .Parameter, {}}, // [4] foo - {0, 5, 3, .Enum, {.ReadOnly}}, // [5] Foo - {0, 7, 1, .EnumMember, {}}, // [6] A + {1, 2, 3, .Enum, {.ReadOnly, .Declaration}}, // [0] Foo + {1, 3, 1, .EnumMember, {}}, // [1] A + {1, 3, 1, .EnumMember, {}}, // [2] B + {3, 2, 3, .Function, {.ReadOnly, .Declaration}}, // [3] bar + {0, 12, 3, .Parameter, {.Declaration}}, // [4] foo + {0, 5, 3, .Enum, {.ReadOnly}}, // [5] Foo + {0, 7, 1, .EnumMember, {}}, // [6] A }) } @@ -176,10 +176,10 @@ semantic_tokens_type_parameter :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Struct, {.ReadOnly}}, // [0] Foo - {0, 15, 1, .TypeParameter, {}}, // [1] A - {1, 3, 3, .Property, {}}, // [2] bar - {0, 5, 1, .TypeParameter, {.ReadOnly}}, // [3] A + {1, 2, 3, .Struct, {.ReadOnly, .Declaration}}, // [0] Foo + {0, 15, 1, .TypeParameter, {.Declaration}}, // [1] A + {1, 3, 3, .Property, {.Declaration}}, // [2] bar + {0, 5, 1, .TypeParameter, {.ReadOnly}}, // [3] A }) } @@ -194,10 +194,10 @@ semantic_tokens_poly_proc :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Function, {.ReadOnly}}, // [0] foo - {0, 12, 1, .Parameter, {}}, // [1] a - {0, 4, 1, .TypeParameter, {}}, // [2] A - {1, 10, 1, .Parameter, {}}, // [3] a + {1, 2, 3, .Function, {.ReadOnly, .Declaration}}, // [0] foo + {0, 12, 1, .Parameter, {.Declaration}}, // [1] a + {0, 4, 1, .TypeParameter, {.Declaration}}, // [2] A + {1, 10, 1, .Parameter, {}}, // [3] a }) } @@ -224,12 +224,12 @@ semantic_tokens_proc_group_selector :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 10, 3, .Namespace, {}}, // [0] pkg (import) - {1, 2, 10, .Function, {.ReadOnly}}, // [1] local_proc - {1, 2, 5, .Function, {.ReadOnly}}, // [2] group - {1, 3, 10, .Function, {.ReadOnly}}, // [3] local_proc - {1, 3, 3, .Namespace, {.ReadOnly}}, // [4] pkg (selector expr) - {0, 4, 9, .Function, {.ReadOnly}}, // [5] some_proc + {1, 10, 3, .Namespace, {}}, // [0] pkg (import) + {1, 2, 10, .Function, {.ReadOnly, .Declaration}}, // [1] local_proc + {1, 2, 5, .Function, {.ReadOnly, .Declaration}}, // [2] group + {1, 3, 10, .Function, {.ReadOnly}}, // [3] local_proc + {1, 3, 3, .Namespace, {.ReadOnly}}, // [4] pkg (selector expr) + {0, 4, 9, .Function, {.ReadOnly}}, // [5] some_proc }) } @@ -242,8 +242,8 @@ semantic_tokens_fixed_capacity_dynamic_array :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Variable, {}}, // [0] foo - {0, 17, 3, .Type, {.ReadOnly}}, // [1] int + {1, 2, 3, .Variable, {.Declaration}}, // [0] foo + {0, 17, 3, .Type, {.ReadOnly}}, // [1] int }) } @@ -264,20 +264,20 @@ semantic_tokens_const_type_cast :: proc(t: ^testing.T) { test.expect_semantic_tokens(t, &src, { // Global scope - {1, 2, 11, .Variable, {.ReadOnly}}, // [0] GLOBAL_TRUE - {0, 15, 4, .Type, {.ReadOnly}}, // [1] bool - {1, 2, 8, .Variable, {.ReadOnly}}, // [2] GLOBAL_A - {0, 15, 3, .Type, {.ReadOnly}}, // [3] int - {1, 2, 8, .Variable, {.ReadOnly}}, // [4] GLOBAL_B - {0, 15, 7, .Type, {.ReadOnly}}, // [5] cstring - {1, 2, 4, .Function, {.ReadOnly}}, // [6] main + {1, 2, 11, .Variable, {.ReadOnly, .Declaration}}, // [0] GLOBAL_TRUE + {0, 15, 4, .Type, {.ReadOnly}}, // [1] bool + {1, 2, 8, .Variable, {.ReadOnly, .Declaration}}, // [2] GLOBAL_A + {0, 15, 3, .Type, {.ReadOnly}}, // [3] int + {1, 2, 8, .Variable, {.ReadOnly, .Declaration}}, // [4] GLOBAL_B + {0, 15, 7, .Type, {.ReadOnly}}, // [5] cstring + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [6] main // Local scope - {1, 3, 4, .Variable, {.ReadOnly}}, // [7] TRUE - {0, 8, 4, .Type, {.ReadOnly}}, // [8] bool - {1, 3, 1, .Variable, {.ReadOnly}}, // [9] A - {0, 8, 3, .Type, {.ReadOnly}}, // [10] int - {1, 3, 1, .Variable, {.ReadOnly}}, // [11] B - {0, 8, 7, .Type, {.ReadOnly}}, // [12] cstring + {1, 3, 4, .Variable, {.ReadOnly, .Declaration}}, // [7] TRUE + {0, 8, 4, .Type, {.ReadOnly}}, // [8] bool + {1, 3, 1, .Variable, {.ReadOnly, .Declaration}}, // [9] A + {0, 8, 3, .Type, {.ReadOnly}}, // [10] int + {1, 3, 1, .Variable, {.ReadOnly, .Declaration}}, // [11] B + {0, 8, 7, .Type, {.ReadOnly}}, // [12] cstring }) } @@ -295,14 +295,14 @@ semantic_tokens_const_alias_type_cast :: proc(t: ^testing.T) { test.expect_semantic_tokens(t, &src, { // Global scope - {1, 2, 4, .Type, {.ReadOnly}}, // [0] Bool - {0, 10, 4, .Type, {.ReadOnly}}, // [1] bool - {1, 2, 6, .Variable, {.ReadOnly}}, // [2] G_TRUE - {0, 10, 4, .Type, {.ReadOnly}}, // [3] Bool - {1, 2, 4, .Function, {.ReadOnly}}, // [4] main + {1, 2, 4, .Type, {.ReadOnly, .Declaration}}, // [0] Bool + {0, 10, 4, .Type, {.ReadOnly}}, // [1] bool + {1, 2, 6, .Variable, {.ReadOnly, .Declaration}}, // [2] G_TRUE + {0, 10, 4, .Type, {.ReadOnly}}, // [3] Bool + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [4] main // Local scope - {1, 3, 4, .Variable, {.ReadOnly}}, // [5] TRUE - {0, 8, 4, .Type, {.ReadOnly}}, // [6] Bool + {1, 3, 4, .Variable, {.ReadOnly, .Declaration}}, // [5] TRUE + {0, 8, 4, .Type, {.ReadOnly}}, // [6] Bool }) } @@ -320,14 +320,14 @@ semantic_tokens_const_array :: proc(t: ^testing.T) { test.expect_semantic_tokens(t, &src, { // Global scope - {1, 2, 3, .Type, {.ReadOnly}}, // [0] Vec - {0, 12, 3, .Type, {.ReadOnly}}, // [1] f32 - {1, 2, 5, .Variable, {.ReadOnly}}, // [2] G_VEC - {0, 9, 3, .Type, {.ReadOnly}}, // [3] Vec - {1, 2, 4, .Function, {.ReadOnly}}, // [4] main + {1, 2, 3, .Type, {.ReadOnly, .Declaration}}, // [0] Vec + {0, 12, 3, .Type, {.ReadOnly}}, // [1] f32 + {1, 2, 5, .Variable, {.ReadOnly, .Declaration}}, // [2] G_VEC + {0, 9, 3, .Type, {.ReadOnly}}, // [3] Vec + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [4] main // Local scope - {1, 3, 3, .Variable, {.ReadOnly}}, // [5] VEC - {0, 7, 3, .Type, {.ReadOnly}}, // [6] Vec + {1, 3, 3, .Variable, {.ReadOnly, .Declaration}}, // [5] VEC + {0, 7, 3, .Type, {.ReadOnly}}, // [6] Vec }) } @@ -341,10 +341,10 @@ semantic_tokens_global_binary_expr :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Variable, {.ReadOnly}}, // [0] FOO - {1, 2, 3, .Variable, {.ReadOnly}}, // [1] BAR - {0, 7, 3, .Type, {.ReadOnly}}, // [2] int - {0, 9, 3, .Type, {.ReadOnly}}, // [3] int + {1, 2, 3, .Variable, {.ReadOnly, .Declaration}}, // [0] FOO + {1, 2, 3, .Variable, {.ReadOnly, .Declaration}}, // [1] BAR + {0, 7, 3, .Type, {.ReadOnly}}, // [2] int + {0, 9, 3, .Type, {.ReadOnly}}, // [3] int }) } @@ -375,16 +375,16 @@ semantic_tokens_imported_symbols :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 10, 10, .Namespace, {}}, // [0] my_package (import) - {1, 2, 4, .Function, {.ReadOnly}}, // [1] main - {1, 7, 10, .Namespace, {.ReadOnly}}, // [2] my_package - {0, 11, 9, .Struct, {.ReadOnly}}, // [3] My_Struct - {1, 7, 10, .Namespace, {.ReadOnly}}, // [4] my_package - {0, 11, 8, .Variable, {.ReadOnly}}, // [5] MY_CONST - {1, 7, 10, .Namespace, {.ReadOnly}}, // [6] my_package - {0, 11, 6, .Variable, {}}, // [7] my_var - {1, 3, 10, .Namespace, {.ReadOnly}}, // [8] my_package - {0, 11, 7, .Function, {.ReadOnly}}, // [9] my_proc + {1, 10, 10, .Namespace, {}}, // [0] my_package (import) + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [1] main + {1, 7, 10, .Namespace, {.ReadOnly}}, // [2] my_package + {0, 11, 9, .Struct, {.ReadOnly}}, // [3] My_Struct + {1, 7, 10, .Namespace, {.ReadOnly}}, // [4] my_package + {0, 11, 8, .Variable, {.ReadOnly}}, // [5] MY_CONST + {1, 7, 10, .Namespace, {.ReadOnly}}, // [6] my_package + {0, 11, 6, .Variable, {}}, // [7] my_var + {1, 3, 10, .Namespace, {.ReadOnly}}, // [8] my_package + {0, 11, 7, .Function, {.ReadOnly}}, // [9] my_proc }) } @@ -410,11 +410,11 @@ semantic_tokens_imported_comp_lit_const :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 10, 6, .Namespace, {}}, // [0] raylib (import) - {1, 2, 4, .Function, {.ReadOnly}}, // [1] main - {1, 3, 1, .Variable, {}}, // [2] c - {0, 5, 6, .Namespace, {.ReadOnly}}, // [3] raylib - {0, 7, 3, .Variable, {.ReadOnly}}, // [4] RED + {1, 10, 6, .Namespace, {}}, // [0] raylib (import) + {1, 2, 4, .Function, {.ReadOnly, .Declaration}}, // [1] main + {1, 3, 1, .Variable, {.Declaration}}, // [2] c + {0, 5, 6, .Namespace, {.ReadOnly}}, // [3] raylib + {0, 7, 3, .Variable, {.ReadOnly}}, // [4] RED }) } @@ -430,10 +430,10 @@ semantic_tokens_enum_field_value :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Enum, {.ReadOnly}}, // [0] Foo - {1, 3, 3, .EnumMember, {}}, // [1] Bar - {1, 3, 3, .EnumMember, {}}, // [2] Baz - {0, 6, 3, .EnumMember, {.ReadOnly}}, // [3] Bar + {1, 2, 3, .Enum, {.ReadOnly, .Declaration}}, // [0] Foo + {1, 3, 3, .EnumMember, {}}, // [1] Bar + {1, 3, 3, .EnumMember, {}}, // [2] Baz + {0, 6, 3, .EnumMember, {.ReadOnly}}, // [3] Bar }) } @@ -447,10 +447,10 @@ semantic_tokens_alias_from_poly_struct :: proc(t: ^testing.T) { } test.expect_semantic_tokens(t, &src, { - {1, 2, 3, .Struct, {.ReadOnly}}, // [0] Foo - {0, 15, 1, .TypeParameter, {}}, // [1] A - {1, 2, 3, .Struct, {.ReadOnly}}, // [2] Bar - {0, 7, 3, .Struct, {.ReadOnly}}, // [3] Foo - {0, 4, 3, .Type, {.ReadOnly}}, // [4] int + {1, 2, 3, .Struct, {.ReadOnly, .Declaration}}, // [0] Foo + {0, 15, 1, .TypeParameter, {.Declaration}}, // [1] A + {1, 2, 3, .Struct, {.ReadOnly, .Declaration}}, // [2] Bar + {0, 7, 3, .Struct, {.ReadOnly}}, // [3] Foo + {0, 4, 3, .Type, {.ReadOnly}}, // [4] int }) }