From 601a1a447aee462575c8de91677991750cb612e5 Mon Sep 17 00:00:00 2001 From: Daniel Gavin Date: Thu, 27 Oct 2022 16:21:12 +0200 Subject: Add support for matrix types --- editors/vscode/syntaxes/odin.tmLanguage.json | 4 +- src/common/ast.odin | 2 +- src/server/analysis.odin | 145 ++++++++++++++++- src/server/collector.odin | 35 ++++ src/server/semantic_tokens.odin | 28 +++- src/server/symbol.odin | 11 ++ src/testing/testing.odin | 4 +- tests/completions_test.odin | 235 +++++++++++++++++---------- tests/hover_test.odin | 14 +- tests/signatures_test.odin | 51 +++--- 10 files changed, 400 insertions(+), 129 deletions(-) diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index a3d2cf3..90c5bd8 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -126,7 +126,7 @@ }, { "name": "storage.type.odin", - "match": "\\b(struct|enum|union|map|set|bit_set|typeid)\\b" + "match": "\\b(struct|enum|union|map|set|bit_set|typeid|matrix)\\b" }, { "name": "keyword.function.odin", @@ -267,7 +267,7 @@ }, { "name": "support.type.odin", - "match": "\\b((f16|f32|f64)|(complex32|complex64|complex128))\\b" + "match": "\\b((f16|f32|f64)|(complex32|complex64|complex128)|(quaternion64|quaternion128|quaternion256))\\b" }, { "name": "support.type.odin", diff --git a/src/common/ast.odin b/src/common/ast.odin index 2a7a027..732c736 100644 --- a/src/common/ast.odin +++ b/src/common/ast.odin @@ -1003,7 +1003,7 @@ repeat :: proc( count: int, allocator := context.allocator, ) -> string { - if count == 0 { + if count <= 0 { return "" } return strings.repeat(value, count, allocator) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 52a05f0..5e4076c 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1142,6 +1142,13 @@ internal_resolve_type_expression :: proc( ast_context.field_name, ), true + case ^Matrix_Type: + return make_symbol_matrix_from_ast( + ast_context, + v^, + ast_context.field_name, + ), + true case ^Dynamic_Array_Type: return make_symbol_dynamic_array_from_ast( ast_context, @@ -1174,7 +1181,7 @@ internal_resolve_type_expression :: proc( case ^Basic_Directive: return resolve_basic_directive(ast_context, v^) case ^Binary_Expr: - return resolve_first_symbol_from_binary_expression(ast_context, v) + return resolve_binary_expression(ast_context, v) case ^Ident: delete_key(&ast_context.recursion_map, v) return internal_resolve_type_identifier(ast_context, v^) @@ -1246,6 +1253,13 @@ internal_resolve_type_expression :: proc( symbol, ok := internal_resolve_type_expression(ast_context, v.elem) symbol.pointers += 1 return symbol, ok + case ^Matrix_Index_Expr: + if symbol, ok := internal_resolve_type_expression(ast_context, v.expr); + ok { + if mat, ok := symbol.value.(SymbolMatrixValue); ok { + return internal_resolve_type_expression(ast_context, mat.expr) + } + } case ^Index_Expr: indexed, ok := internal_resolve_type_expression(ast_context, v.expr) @@ -1663,6 +1677,9 @@ internal_resolve_type_identifier :: proc( case ^Dynamic_Array_Type: return_symbol, ok = make_symbol_dynamic_array_from_ast(ast_context, v^, node), true + case ^Matrix_Type: + return_symbol, ok = + make_symbol_matrix_from_ast(ast_context, v^, node), true case ^Map_Type: return_symbol, ok = make_symbol_map_from_ast(ast_context, v^, node), true @@ -1760,6 +1777,9 @@ internal_resolve_type_identifier :: proc( case ^Dynamic_Array_Type: return_symbol, ok = make_symbol_dynamic_array_from_ast(ast_context, v^, node), true + case ^Matrix_Type: + return_symbol, ok = + make_symbol_matrix_from_ast(ast_context, v^, node), true case ^Map_Type: return_symbol, ok = make_symbol_map_from_ast(ast_context, v^, node), true @@ -2113,10 +2133,7 @@ resolve_first_symbol_from_binary_expression :: proc( Symbol, bool, ) { - //Fairly simple function to find the earliest identifier symbol in binary expression. - if binary.left != nil { - if ident, ok := binary.left.derived.(^ast.Ident); ok { if s, ok := resolve_type_identifier(ast_context, ident^); ok { return s, ok @@ -2149,6 +2166,72 @@ resolve_first_symbol_from_binary_expression :: proc( return {}, false } +resolve_binary_expression :: proc( + ast_context: ^AstContext, + binary: ^ast.Binary_Expr, +) -> ( + Symbol, + bool, +) { + if binary.left == nil || binary.right == nil { + return {}, false + } + + symbol_a, symbol_b: Symbol + ok_a, ok_b: bool + + if expr, ok := binary.left.derived.(^ast.Binary_Expr); ok { + symbol_a, ok_a = resolve_binary_expression(ast_context, expr) + } else { + ast_context.use_locals = true + symbol_a, ok_a = resolve_type_expression(ast_context, binary.left) + } + + if expr, ok := binary.right.derived.(^ast.Binary_Expr); ok { + symbol_b, ok_b = resolve_binary_expression(ast_context, expr) + } else { + ast_context.use_locals = true + symbol_b, ok_b = resolve_type_expression(ast_context, binary.right) + } + + if !ok_a || !ok_b { + return {}, false + } + + matrix_value_a, is_matrix_a := symbol_a.value.(SymbolMatrixValue) + matrix_value_b, is_matrix_b := symbol_b.value.(SymbolMatrixValue) + + vector_value_a, is_vector_a := symbol_a.value.(SymbolFixedArrayValue) + vector_value_b, is_vector_b := symbol_b.value.(SymbolFixedArrayValue) + + //Handle matrix multication specially because it can actual change the return type dimension + if is_matrix_a && is_matrix_b && binary.op.kind == .Mul { + symbol_a.value = SymbolMatrixValue { + expr = matrix_value_a.expr, + x = matrix_value_a.x, + y = matrix_value_b.y, + } + return symbol_a, true + } else if is_matrix_a && is_vector_b && binary.op.kind == .Mul { + symbol_a.value = SymbolFixedArrayValue { + expr = matrix_value_a.expr, + len = matrix_value_a.y, + } + return symbol_a, true + + } else if is_vector_a && is_matrix_b && binary.op.kind == .Mul { + symbol_a.value = SymbolFixedArrayValue { + expr = matrix_value_b.expr, + len = matrix_value_b.x, + } + return symbol_a, true + } + + + //Otherwise just choose the first type, we do not handle error cases - that is done with the checker + return symbol_a, ok_a +} + find_position_in_call_param :: proc( ast_context: ^AstContext, call: ast.Call_Expr, @@ -2327,6 +2410,28 @@ make_symbol_dynamic_array_from_ast :: proc( return symbol } +make_symbol_matrix_from_ast :: proc( + ast_context: ^AstContext, + v: ast.Matrix_Type, + name: ast.Ident, +) -> Symbol { + symbol := Symbol { + range = common.get_token_range(v.node, ast_context.file.src), + type = .Constant, + pkg = get_package_from_node(v.node), + name = name.name, + } + + symbol.value = SymbolMatrixValue { + expr = v.elem, + x = v.row_count, + y = v.column_count, + } + + return symbol +} + + make_symbol_multi_pointer_from_ast :: proc( ast_context: ^AstContext, v: ast.Multi_Pointer_Type, @@ -3865,13 +3970,19 @@ get_signature :: proc( return "proc" case SymbolStructValue: if is_variable { - return symbol.name + return strings.concatenate( + {pointer_prefix, symbol.name}, + ast_context.allocator, + ) } else { return "struct" } case SymbolUnionValue: if is_variable { - return symbol.name + return strings.concatenate( + {pointer_prefix, symbol.name}, + ast_context.allocator, + ) } else { return "union" } @@ -3901,6 +4012,20 @@ get_signature :: proc( }, allocator = ast_context.allocator, ) + case SymbolMatrixValue: + return strings.concatenate( + a = { + pointer_prefix, + "matrix", + "[", + common.node_to_string(v.x), + ",", + common.node_to_string(v.y), + "]", + common.node_to_string(v.expr), + }, + allocator = ast_context.allocator, + ) case SymbolPackageValue: return "package" case SymbolUntypedValue: @@ -4553,6 +4678,14 @@ get_document_position_node :: proc( } case ^Undef: case ^Basic_Lit: + case ^Matrix_Index_Expr: + get_document_position(n.expr, position_context) + get_document_position(n.row_index, position_context) + get_document_position(n.column_index, position_context) + case ^Matrix_Type: + get_document_position(n.row_count, position_context) + get_document_position(n.column_count, position_context) + get_document_position(n.elem, position_context) case ^Ellipsis: get_document_position(n.expr, position_context) case ^Proc_Lit: diff --git a/src/server/collector.odin b/src/server/collector.odin index 9a7d050..b065a9e 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -320,6 +320,36 @@ collect_dynamic_array :: proc( return SymbolDynamicArrayValue{expr = elem} } +collect_matrix :: proc( + collection: ^SymbolCollection, + mat: ast.Matrix_Type, + package_map: map[string]string, +) -> SymbolMatrixValue { + elem := clone_type( + mat.elem, + collection.allocator, + &collection.unique_strings, + ) + + y := clone_type( + mat.column_count, + collection.allocator, + &collection.unique_strings, + ) + + x := clone_type( + mat.row_count, + collection.allocator, + &collection.unique_strings, + ) + + replace_package_alias(elem, package_map, collection) + replace_package_alias(x, package_map, collection) + replace_package_alias(y, package_map, collection) + + return SymbolMatrixValue{expr = elem, x = x, y = y} +} + collect_multi_pointer :: proc( collection: ^SymbolCollection, array: ast.Multi_Pointer_Type, @@ -336,6 +366,7 @@ collect_multi_pointer :: proc( return SymbolMultiPointer{expr = elem} } + collect_generic :: proc( collection: ^SymbolCollection, expr: ^ast.Expr, @@ -410,6 +441,10 @@ collect_symbols :: proc( } #partial switch v in col_expr.derived { + case ^ast.Matrix_Type: + token = v^ + token_type = .Variable + symbol.value = collect_matrix(collection, v^, package_map) case ^ast.Proc_Lit: token = v^ token_type = .Function diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin index f930530..8733be4 100644 --- a/src/server/semantic_tokens.odin +++ b/src/server/semantic_tokens.odin @@ -262,7 +262,6 @@ visit_node :: proc( if symbol_and_node, ok := builder.symbols[cast(uintptr)node]; ok { if .Distinct in symbol_and_node.symbol.flags && symbol_and_node.symbol.type == .Constant { - log.error(symbol_and_node.symbol) write_semantic_node( builder, node, @@ -273,8 +272,7 @@ visit_node :: proc( return } - if symbol_and_node.symbol.type == .Variable || - symbol_and_node.symbol.type == .Constant { + if symbol_and_node.symbol.type == .Variable { write_semantic_node( builder, node, @@ -350,6 +348,14 @@ visit_node :: proc( .Type, .None, ) + case SymbolMatrixValue: + write_semantic_node( + builder, + node, + ast_context.file.src, + .Type, + .None, + ) case: //log.errorf("Unexpected symbol value: %v", symbol.value); //panic(fmt.tprintf("Unexpected symbol value: %v", symbol.value)); @@ -386,6 +392,22 @@ visit_node :: proc( visit(n.stmts, builder, ast_context) case ^Expr_Stmt: visit(n.expr, builder, ast_context) + case ^Matrix_Type: + write_semantic_string( + builder, + n.tok_pos, + "matrix", + ast_context.file.src, + .Keyword, + .None, + ) + visit(n.row_count, builder, ast_context) + visit(n.column_count, builder, ast_context) + visit(n.elem, builder, ast_context) + case ^ast.Matrix_Index_Expr: + visit(n.expr, builder, ast_context) + visit(n.row_index, builder, ast_context) + visit(n.column_index, builder, ast_context) case ^Branch_Stmt: write_semantic_token( builder, diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 0c6a4dc..215e01c 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -89,6 +89,12 @@ SymbolMapValue :: struct { value: ^ast.Expr, } +SymbolMatrixValue :: struct { + x: ^ast.Expr, + y: ^ast.Expr, + expr: ^ast.Expr, +} + /* Generic symbol that is used by the indexer for any variable type(constants, defined global variables, etc), */ @@ -113,6 +119,7 @@ SymbolValue :: union { SymbolSliceValue, SymbolBasicValue, SymbolUntypedValue, + SymbolMatrixValue, } SymbolFlag :: enum { @@ -178,6 +185,10 @@ free_symbol :: proc(symbol: Symbol, allocator: mem.Allocator) { } switch v in symbol.value { + case SymbolMatrixValue: + common.free_ast(v.expr, allocator) + common.free_ast(v.x, allocator) + common.free_ast(v.y, allocator) case SymbolMultiPointer: common.free_ast(v.expr, allocator) case SymbolProcedureValue: diff --git a/src/testing/testing.odin b/src/testing/testing.odin index e4ac86d..0d97870 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -58,9 +58,9 @@ setup :: proc(src: ^Source) { } else if current == '\n' { current_line += 1 current_character = 0 - } else if current == '*' { + } else if src.main[current_index:current_index + 3] == "{*}" { dst_slice := transmute([]u8)src.main[current_index:] - src_slice := transmute([]u8)src.main[current_index + 1:] + src_slice := transmute([]u8)src.main[current_index + 3:] copy(dst_slice, src_slice) src.position.character = current_character src.position.line = current_line diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 9d9667f..21b89a2 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -18,7 +18,7 @@ ast_simple_struct_completion :: proc(t: ^testing.T) { main :: proc() { my_struct: My_Struct; - my_struct.* + my_struct.{*} } `, packages = {}, @@ -45,7 +45,7 @@ ast_index_array_completion :: proc(t: ^testing.T) { main :: proc() { my_struct: [] My_Struct; - my_struct[2].* + my_struct[2].{*} } `, packages = {}, @@ -72,7 +72,7 @@ ast_struct_pointer_completion :: proc(t: ^testing.T) { main :: proc() { my_struct: ^My_Struct; - my_struct.* + my_struct.{*} } `, packages = {}, @@ -100,7 +100,7 @@ ast_struct_take_address_completion :: proc(t: ^testing.T) { main :: proc() { my_struct: My_Struct; my_pointer := &my_struct; - my_pointer.* + my_pointer.{*} } `, packages = {}, @@ -128,7 +128,7 @@ ast_struct_deref_completion :: proc(t: ^testing.T) { main :: proc() { my_struct: ^^My_Struct; my_deref := my_struct^; - my_deref.* + my_deref.{*} } `, packages = {}, @@ -157,7 +157,7 @@ ast_range_map :: proc(t: ^testing.T) { my_map: map[int]My_Struct; for key, value in my_map { - value.* + value.{*} } } @@ -188,7 +188,7 @@ ast_range_array :: proc(t: ^testing.T) { my_array: []My_Struct; for value in my_array { - value.* + value.{*} } } @@ -224,7 +224,7 @@ ast_completion_identifier_proc_group :: proc(t: ^testing.T) { }; main :: proc() { - grou* + grou{*} } `, packages = {}, @@ -250,7 +250,7 @@ ast_completion_in_comp_lit_type :: proc(t: ^testing.T) { } main :: proc() { - my_comp := My_* { + my_comp := My_{*} { }; } `, @@ -274,7 +274,7 @@ ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) { my_struct: My_Struct; for value in my_struct.array { - val* + val{*} } } `, @@ -286,7 +286,6 @@ ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) { @(test) ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) { - source := test.Source { main = `package test @@ -302,7 +301,7 @@ ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) { main :: proc() { my_struct: My_Struct; - my_struct.array[len(my_struct.array)-1].* + my_struct.array[len(my_struct.array)-1].{*} } `, packages = {}, @@ -341,7 +340,7 @@ index_package_completion :: proc(t: ^testing.T) { import "my_package" main :: proc() { - my_package.* + my_package.{*} } `, packages = packages[:], @@ -378,7 +377,7 @@ ast_generic_make_slice :: proc(t: ^testing.T) { main :: proc() { my_slice := make_slice([]My_Struct, 23); - my_slic* + my_slic{*} } `, packages = {}, @@ -407,7 +406,7 @@ ast_named_procedure_1 :: proc(t: ^testing.T) { main :: proc() { my_bool := my_group(b = false, a = 2); - my_boo* + my_boo{*} } `, packages = {}, @@ -430,7 +429,7 @@ ast_named_procedure_2 :: proc(t: ^testing.T) { main :: proc() { my_bool := my_group(b = false); - my_boo* + my_boo{*} } `, packages = {}, @@ -445,7 +444,7 @@ ast_swizzle_completion :: proc(t: ^testing.T) { main = `package test main :: proc() { my_array: [4] f32; - my_array.* + my_array.{*} } `, packages = {}, @@ -474,7 +473,7 @@ ast_swizzle_completion_one_component :: proc(t: ^testing.T) { main = `package test main :: proc() { my_array: [4] f32; - my_array.x* + my_array.x{*} } `, packages = {}, @@ -494,7 +493,7 @@ ast_swizzle_completion_few_components :: proc(t: ^testing.T) { main = `package test main :: proc() { my_array: [2] f32; - my_array.x* + my_array.x{*} } `, packages = {}, @@ -516,7 +515,7 @@ ast_swizzle_resolve_one_components :: proc(t: ^testing.T) { main :: proc() { my_array: [4]f32; my_swizzle := my_array.x; - my_swizz* + my_swizz{*} } `, packages = {}, @@ -532,7 +531,7 @@ ast_swizzle_resolve_two_components :: proc(t: ^testing.T) { main :: proc() { my_array: [4]f32; my_swizzle := my_array.xx; - my_swizz* + my_swizz{*} } `, packages = {}, @@ -551,7 +550,7 @@ ast_swizzle_resolve_one_component_struct_completion :: proc(t: ^testing.T) { }; main :: proc() { my_array: [4] My_Struct; - my_array.x.* + my_array.x.{*} } `, packages = {}, @@ -581,7 +580,7 @@ ast_for_in_identifier_completion :: proc(t: ^testing.T) { for my_element in my_array { - my_elem* + my_elem{*} } } @@ -610,7 +609,7 @@ ast_completion_poly_struct_proc :: proc(t: ^testing.T) { } execute_lighting_pass2 :: proc(pass : RenderPass(LightingAccumPass2)) { - pass.* + pass.{*} } `, packages = {}, @@ -649,7 +648,7 @@ ast_generic_make_completion :: proc(t: ^testing.T) { main :: proc() { allocator: Allocator; my_array := make([dynamic]My_Struct, 343); - my_array[2].* + my_array[2].{*} } `, packages = {}, @@ -689,7 +688,7 @@ ast_generic_make_completion_2 :: proc(t: ^testing.T) { main :: proc() { allocator: Allocator; my_array := make([]My_Struct, 343); - my_array[2].* + my_array[2].{*} } `, packages = {}, @@ -718,7 +717,7 @@ ast_struct_for_in_switch_stmt_completion :: proc(t: ^testing.T) { switch (message) { case win32.WM_SIZE: for w in platform_context.windows { - w.* + w.{*} } } } @@ -745,7 +744,7 @@ ast_overload_with_autocast_completion :: proc(t: ^testing.T) { main :: proc() { my_uint: uint = 0; my_value := my_group(my_uint); - my_val* + my_val{*} } `, packages = {}, @@ -772,7 +771,7 @@ ast_overload_with_any_int_completion :: proc(t: ^testing.T) { main :: proc() { my_uint: uint = 0; my_value := my_group(my_uint); - my_val* + my_val{*} } `, packages = {}, @@ -798,7 +797,7 @@ ast_overload_with_any_int_with_poly_completion :: proc(t: ^testing.T) { main :: proc() { my_uint: uint = 0; my_value := my_group([dynamic]f32, my_uint); - my_val* + my_val{*} } `, packages = {}, @@ -821,7 +820,7 @@ ast_completion_in_between_struct :: proc(t: ^testing.T) { current_token: ^Format_Token, previous_token: ^Format_Token, line: ^Unwrapped_Line, - a* + a{*} indent: int, width: int, penalty: f32, @@ -864,7 +863,7 @@ ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) { main :: proc() { my_uint: uint = 0; my_value := my_package.my_group([dynamic]f32, my_uint); - my_val* + my_val{*} } `, packages = packages[:], @@ -900,7 +899,7 @@ ast_package_procedure_completion :: proc(t: ^testing.T) { import "my_package" main :: proc() { - my_package.* + my_package.{*} } `, packages = packages[:], @@ -928,7 +927,7 @@ ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) { main :: proc() { t := new_type(My_Struct, {}, {}) - t.* + t.{*} } `, packages = {}, @@ -946,7 +945,7 @@ ast_global_struct_completion :: proc(t: ^testing.T) { Foo :: struct { x: int } foo := Foo{} main :: proc() { - x := foo.* + x := foo.{*} } `, packages = {}, @@ -962,7 +961,7 @@ ast_global_non_mutable_completion :: proc(t: ^testing.T) { Foo :: struct { x: int } main :: proc() { - x := Foo.* + x := Foo.{*} } `, packages = {}, @@ -978,7 +977,7 @@ ast_basic_value_untyped_completion :: proc(t: ^testing.T) { main :: proc() { xaa := 2 - xa* + xa{*} } `, packages = {}, @@ -995,7 +994,7 @@ ast_basic_value_binary_completion :: proc(t: ^testing.T) { main :: proc() { xaa := 2 xb2 := xaa - 2 - xb* + xb{*} } `, packages = {}, @@ -1024,7 +1023,7 @@ ast_file_private_completion :: proc(t: ^testing.T) { main = `package main import "my_package" main :: proc() { - my_package.* + my_package.{*} } `, packages = packages[:], @@ -1052,7 +1051,7 @@ ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) { main = `package main import "my_package" main :: proc() { - my_package.* + my_package.{*} } `, packages = packages[:], @@ -1080,7 +1079,7 @@ ast_mutable_variable_struct_completion :: proc(t: ^testing.T) { main = `package main import "my_package" main :: proc() { - my_package.var.* + my_package.var.{*} } `, packages = packages[:], @@ -1097,7 +1096,7 @@ ast_out_of_block_scope_completion :: proc(t: ^testing.T) { { aabb := 2 } - aab* + aab{*} } `, } @@ -1112,7 +1111,7 @@ ast_value_decl_multiple_name_same_type :: proc(t: ^testing.T) { main :: proc() { xaaaa, yaaaa: string xaaaa = "hi" - yaaa* + yaaa{*} } `, } @@ -1132,7 +1131,7 @@ ast_value_decl_comp_lit :: proc(t: ^testing.T) { a = 2, } - my_struct.* + my_struct.{*} } `, } @@ -1146,7 +1145,7 @@ ast_multi_pointer_completion :: proc(t: ^testing.T) { main = `package main main :: proc() { faa: [^]int - fa* + fa{*} } `, } @@ -1161,7 +1160,7 @@ ast_multi_pointer_indexed_completion :: proc(t: ^testing.T) { main :: proc() { faa: [^]int sap := faa[1] - sa* + sa{*} } `, } @@ -1181,7 +1180,7 @@ ast_implicit_named_comp_lit_bitset :: proc(t: ^testing.T) { main :: proc() { inst := My_Struct { - bits = {.*} + bits = {.{*}} } } `, @@ -1203,7 +1202,7 @@ ast_implicit_unnamed_comp_lit_bitset :: proc(t: ^testing.T) { main :: proc() { inst := My_Struct { - {.A}, {.*}, + {.A}, {.{*}}, } } `, @@ -1225,7 +1224,7 @@ ast_implicit_unnamed_comp_lit_enum :: proc(t: ^testing.T) { main :: proc() { inst := My_Struct { - .A, .* + .A, .{*} } } `, @@ -1250,7 +1249,7 @@ ast_implicit_mixed_named_and_unnamed_comp_lit_bitset :: proc(t: ^testing.T) { main :: proc() { inst := My_Struct { - foo = {{.A}, {.*}, {.B} } + foo = {{.A}, {.{*}}, {.B} } } } `, @@ -1274,7 +1273,7 @@ ast_comp_lit_in_complit_completion :: proc(t: ^testing.T) { main :: proc() { inst := My_Struct { foo = { - a* + a{*} } } } @@ -1302,7 +1301,7 @@ ast_inlined_struct :: proc(t: ^testing.T) { main :: proc() { inst: My_Struct - inst.foo.* + inst.foo.{*} } `, } @@ -1326,7 +1325,7 @@ ast_inlined_union :: proc(t: ^testing.T) { main :: proc() { inst: My_Struct - inst.* + inst.{*} } `, } @@ -1348,7 +1347,7 @@ ast_union_identifier_completion :: proc(t: ^testing.T) { } main :: proc() { - a: My_* + a: My_{*} } `, } @@ -1364,7 +1363,7 @@ ast_union_poly :: proc(t: ^testing.T) { main :: proc() { m: My_Union(int) - m.* + m.{*} } `, } @@ -1381,7 +1380,7 @@ ast_maybe_first_value :: proc(t: ^testing.T) { main :: proc() { m: Maybe(int) v, ok := m.? - v* + v{*} } `, } @@ -1396,7 +1395,7 @@ ast_maybe_second_value :: proc(t: ^testing.T) { main :: proc() { m: Maybe(int) v, ok := m.? - ok* + ok{*} } `, } @@ -1412,7 +1411,7 @@ ast_maybe_array :: proc(t: ^testing.T) { main :: proc() { m: My_Union([5]u8) - m.* + m.{*} } `, } @@ -1440,7 +1439,7 @@ ast_maybe_index_completion :: proc(t: ^testing.T) { import "my_package" main :: proc() { m: my_package.Maybe(int) - m.* + m.{*} } `, packages = packages[:], @@ -1457,7 +1456,7 @@ ast_distinct_u32_completion :: proc(t: ^testing.T) { Distinct_Type :: distinct u32 d: Distinct_Type - d* + d{*} } `, } @@ -1474,7 +1473,7 @@ ast_new_completion :: proc(t: ^testing.T) { main :: proc() { adzz := new(int); - adzz* + adzz{*} } `, @@ -1494,7 +1493,7 @@ ast_new_clone_completion :: proc(t: ^testing.T) { main :: proc() { adzz := new_clone(Foo{}); - adzz* + adzz{*} } `, @@ -1511,7 +1510,7 @@ ast_rawtr_cast_completion :: proc(t: ^testing.T) { main :: proc() { raw: rawptr my_int := cast(int)raw; - my_i* + my_i{*} } `, @@ -1538,7 +1537,7 @@ ast_overload_with_procedure_return :: proc(t: ^testing.T) { test_int :: proc() -> int {} main :: proc() { my_in := my_group([]int, test_int()) - my_in* + my_in{*} } `, } @@ -1568,7 +1567,7 @@ ast_index_proc_parameter_completion :: proc(t: ^testing.T) { main = `package main import "my_package" f :: proc(param: my_package.My_Struct) { - para* + para{*} } `, packages = packages[:], @@ -1590,7 +1589,7 @@ ast_implicit_completion_in_enum_array_comp_lit :: proc(t: ^testing.T) { foo :: enum{ one, two } bar := [foo]int{ .one = 1, - .*two = 2, + .{*}two = 2, } } `, @@ -1606,7 +1605,7 @@ ast_implicit_enum_value_decl_type :: proc(t: ^testing.T) { main = `package main Foo :: enum { Aa, Ab, Ac, Ad } main :: proc() { - foo: Foo = .* + foo: Foo = .{*} } `, } @@ -1621,7 +1620,7 @@ ast_implicit_bitset_value_decl :: proc(t: ^testing.T) { Foo :: enum { Aa, Ab, Ac, Ad } Foo_Set :: bit_set[Foo] main :: proc() { - foo_set := Foo_Set { .* } + foo_set := Foo_Set { .{*} } } `, } @@ -1637,7 +1636,7 @@ ast_implicit_bitset_add :: proc(t: ^testing.T) { Foo_Set :: bit_set[Foo] main :: proc() { foo_set: Foo_Set - foo_set += .* + foo_set += .{*} } `, } @@ -1651,7 +1650,7 @@ ast_enum_complete :: proc(t: ^testing.T) { main = `package main Foo :: enum { Aa, Ab, Ac, Ad } main :: proc() { - foo := Foo.* + foo := Foo.{*} } `, } @@ -1688,7 +1687,7 @@ ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) { import "my_package" main :: proc() { a := my_package.Bar { - c = .* + c = .{*} } } `, @@ -1725,7 +1724,7 @@ ast_package_uppercase_test :: proc(t: ^testing.T) { main = `package main import "My_package" main :: proc() { - My_package.* + My_package.{*} } `, packages = packages[:], @@ -1763,7 +1762,7 @@ ast_index_enum_infer :: proc(t: ^testing.T) { main :: proc() { my_enum: My_package.Foo - if my_enum == *. + if my_enum == {*}. } `, packages = packages[:], @@ -1777,7 +1776,7 @@ ast_index_builtin_ODIN_OS :: proc(t: ^testing.T) { source := test.Source { main = `package test main :: proc() { - when ODIN_OS == .* + when ODIN_OS == .{*} } `, packages = {}, @@ -1794,7 +1793,7 @@ ast_for_in_range_half_completion_1 :: proc(t: ^testing.T) { ints: []int for int_idx in 0..