From 035a0db206ae1651b8e853b5aff5c1562fc7715e Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Thu, 18 Sep 2025 08:43:09 -0400 Subject: Rework how hover info is displayed for constants and types --- src/server/analysis.odin | 2 + src/server/documentation.odin | 23 +++- src/server/hover.odin | 1 + src/server/signature.odin | 1 + tests/completions_test.odin | 36 +++--- tests/hover_test.odin | 258 +++++++++++++++++++++--------------------- tests/signatures_test.odin | 52 ++++----- 7 files changed, 198 insertions(+), 175 deletions(-) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 684a790..1e570b4 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1348,6 +1348,7 @@ resolve_soa_selector_field :: proc( if resolved, ok := resolve_type_expression(ast_context, v.types[i]); ok { resolved.pkg = symbol.name resolved.range = v.ranges[i] + resolved.type = .Field return resolved, ok } else { return {}, false @@ -2618,6 +2619,7 @@ resolve_type_location_proc_param_name :: proc( symbol.type_name = symbol.name symbol.pkg = call_symbol.name symbol.name = ident.name + symbol.type = .Field return symbol, true } } diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 7979e5a..53c9c36 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -430,6 +430,19 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy strings.write_string(sb, "package") return case SymbolUntypedValue: + if .Mutable in symbol.flags || symbol.type == .Field { + switch v.type { + case .Float: + strings.write_string(sb, "float") + case .String: + strings.write_string(sb, "string") + case .Bool: + strings.write_string(sb, "bool") + case .Integer: + strings.write_string(sb, "int") + } + return + } strings.write_string(sb, v.tok.text) return case SymbolGenericValue: @@ -789,7 +802,12 @@ construct_symbol_information :: proc(ast_context: ^AstContext, symbol: Symbol) - sb := strings.builder_make(ast_context.allocator) write_symbol_attributes(&sb, symbol) write_symbol_name(&sb, symbol) - if .Mutable not_in symbol.flags { + + if symbol.type == .Package { + return strings.to_string(sb) + } + + if symbol.type != .Field && .Mutable not_in symbol.flags { if symbol.type_expr != nil && symbol.value_expr != nil { strings.write_string(&sb, " : ") build_string_node(symbol.type_expr, &sb, false) @@ -802,9 +820,6 @@ construct_symbol_information :: proc(ast_context: ^AstContext, symbol: Symbol) - strings.write_string(&sb, ": ") } - if symbol.type == .Package { - return strings.to_string(sb) - } if write_symbol_type_information(&sb, ast_context, symbol) { return strings.to_string(sb) diff --git a/src/server/hover.odin b/src/server/hover.odin index ef4c046..fe69949 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -344,6 +344,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> name = selector.name, pkg = selector.pkg, signature = get_enum_field_signature(v, i), + type = .Field, } hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true diff --git a/src/server/signature.odin b/src/server/signature.odin index 619453f..9ffe92b 100644 --- a/src/server/signature.odin +++ b/src/server/signature.odin @@ -187,6 +187,7 @@ get_signature_information :: proc(document: ^Document, position: common.Position get_signature :: proc(symbol: Symbol) -> string { sb := strings.builder_make() write_symbol_name(&sb, symbol) + strings.write_string(&sb, " :: ") strings.write_string(&sb, symbol.signature) return strings.to_string(sb) } diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 7b42568..13196a3 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -223,7 +223,7 @@ ast_completion_identifier_proc_group :: proc(t: ^testing.T) { packages = {}, } - test.expect_completion_docs(t, &source, "", {"test.group_function: proc (..)"}) + test.expect_completion_docs(t, &source, "", {"test.group_function :: proc (..)"}) } @(test) @@ -244,7 +244,7 @@ ast_completion_identifier_proc_group_2 :: proc(t: ^testing.T) { `, } - test.expect_completion_docs(t, &source, "", {"test.zzcool: proc(v: $T/[]$E) -> [^]E"}) + test.expect_completion_docs(t, &source, "", {"test.zzcool :: proc(v: $T/[]$E) -> [^]E"}) } @(test) @@ -289,7 +289,7 @@ ast_completion_in_comp_lit_type :: proc(t: ^testing.T) { packages = {}, } - test.expect_completion_docs(t, &source, "", {"test.My_Struct: struct {..}"}) + test.expect_completion_docs(t, &source, "", {"test.My_Struct :: struct {..}"}) } @(test) @@ -373,7 +373,7 @@ index_package_completion :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"my_package.My_Struct: struct {..}"}) + test.expect_completion_docs(t, &source, ".", {"my_package.My_Struct :: struct {..}"}) } @(test) @@ -961,7 +961,7 @@ ast_package_procedure_completion :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"my_package.my_proc: proc() -> bool"}) + test.expect_completion_docs(t, &source, ".", {"my_package.my_proc :: proc() -> bool"}) } @(test) @@ -1137,7 +1137,7 @@ ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"my_package.Im: struct {..}"}) + test.expect_completion_docs(t, &source, ".", {"my_package.Im :: struct {..}"}) } @(test) @@ -1461,7 +1461,7 @@ ast_union_identifier_completion :: proc(t: ^testing.T) { `, } - test.expect_completion_docs(t, &source, ".", {"test.My_Union: union {..}"}) + test.expect_completion_docs(t, &source, ".", {"test.My_Union :: union {..}"}) } @(test) @@ -1606,7 +1606,7 @@ ast_new_completion_for_proc_defined :: proc(t: ^testing.T) { `, } - test.expect_completion_docs(t, &source, "", {"test.Http_Ctx: struct {..}"}) + test.expect_completion_docs(t, &source, "", {"test.Http_Ctx :: struct {..}"}) } @(test) @@ -1851,7 +1851,7 @@ ast_package_uppercase_test :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"My_package.Foo: enum {..}", "My_package.Bar: struct {..}"}) + test.expect_completion_docs(t, &source, ".", {"My_package.Foo :: enum {..}", "My_package.Bar :: struct {..}"}) } @@ -2013,7 +2013,7 @@ ast_procedure_in_procedure_non_mutable_completion :: proc(t: ^testing.T) { packages = {}, } - test.expect_completion_docs(t, &source, "", {"test.Int: int"}) + test.expect_completion_docs(t, &source, "", {"test.Int :: int"}) } @(test) @@ -2381,7 +2381,7 @@ ast_local_global_function :: proc(t: ^testing.T) { `, } - test.expect_completion_docs(t, &source, "", {"test.my_function_two: proc(one: int)"}) + test.expect_completion_docs(t, &source, "", {"test.my_function_two :: proc(one: int)"}) } @(test) @@ -3853,7 +3853,7 @@ ast_completion_using_aliased_package :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"my_package.foo: proc()"}) + test.expect_completion_docs(t, &source, ".", {"my_package.foo :: proc()"}) } @(test) @@ -3883,7 +3883,7 @@ ast_completion_using_aliased_package_multiple :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_completion_docs(t, &source, ".", {"foo_pkg.foo: proc()"}) + test.expect_completion_docs(t, &source, ".", {"foo_pkg.foo :: proc()"}) } @(test) @@ -4245,7 +4245,7 @@ ast_completion_proc_variadiac_arg :: proc(t: ^testing.T) { foo :: proc(foos: ..{*}) {} `, } - test.expect_completion_docs(t, &source, "", {"test.Foo: enum {..}"}) + test.expect_completion_docs(t, &source, "", {"test.Foo :: enum {..}"}) } @(test) @@ -4265,7 +4265,7 @@ ast_completion_within_struct_decl :: proc(t: ^testing.T) { } `, } - test.expect_completion_docs(t, &source, "", {"test.Foo: enum {..}"}, {"test.foo: proc(f: Foo)"}) + test.expect_completion_docs(t, &source, "", {"test.Foo :: enum {..}"}, {"test.foo :: proc(f: Foo)"}) } @(test) @@ -4595,7 +4595,7 @@ ast_completion_poly_proc_narrow_type :: proc(t: ^testing.T) { foo :: proc (a: $T/F{*}) {} `, } - test.expect_completion_docs(t, &source, "", {"test.Foo: struct {..}"}) + test.expect_completion_docs(t, &source, "", {"test.Foo :: struct {..}"}) } @(test) @@ -4681,7 +4681,7 @@ ast_completion_struct_field_name :: proc(t: ^testing.T) { } `, } - test.expect_completion_docs(t, &source, "", {}, {"test.Foo: struct {}"}) + test.expect_completion_docs(t, &source, "", {}, {"test.Foo :: struct {}"}) } @(test) @@ -4696,7 +4696,7 @@ ast_completion_struct_field_value :: proc(t: ^testing.T) { } `, } - test.expect_completion_docs(t, &source, "", {"test.Foo: struct {}"}) + test.expect_completion_docs(t, &source, "", {"test.Foo :: struct {}"}) } @(test) diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 6800556..ee43c50 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -22,7 +22,7 @@ ast_hover_in_nested_blocks :: proc(t: ^testing.T) { packages = {}, } - test.expect_hover(t, &source, "test.My_Struct: struct {\n\tproperty: int,\n}") + test.expect_hover(t, &source, "test.My_Struct :: struct {\n\tproperty: int,\n}") } @(test) @@ -58,7 +58,7 @@ ast_hover_default_parameter_enum :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.procedure: proc(called_from: Expr_Called_Type = .None, options := List_Options{})", + "test.procedure :: proc(called_from: Expr_Called_Type = .None, options := List_Options{})", ) } @(test) @@ -182,7 +182,7 @@ ast_hover_procedure_with_default_comp_lit :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.fa: proc(color_: Color = {255, 255, 255, 255})") + test.expect_hover(t, &source, "test.fa :: proc(color_: Color = {255, 255, 255, 255})") } @(test) @@ -226,7 +226,7 @@ ast_hover_on_array_variable :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Vec: [2]f32") + test.expect_hover(t, &source, "test.Vec :: [2]f32") } @(test) @@ -237,7 +237,7 @@ ast_hover_on_array_infer_length_variable :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.vec: [?]f32") + test.expect_hover(t, &source, "test.vec :: [?]f32") } @(test) @@ -352,7 +352,7 @@ ast_hover_struct_field_selector_completion :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.My_Struct: struct {\n\tone: int,\n\ttwo: int,\n\tthree: int,\n}") + test.expect_hover(t, &source, "my_package.My_Struct :: struct {\n\tone: int,\n\ttwo: int,\n\tthree: int,\n}") } @(test) @@ -377,7 +377,7 @@ ast_hover_package_with_value_decl_same_name :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.my_package: proc() -> int") + test.expect_hover(t, &source, "my_package.my_package :: proc() -> int") } @@ -402,7 +402,7 @@ ast_hover_proc_group :: proc(t: ^testing.T) { packages = {}, } - test.expect_hover(t, &source, "test.add: proc(a, b: int) -> int\n docs\n\n// comment") + test.expect_hover(t, &source, "test.add :: proc(a, b: int) -> int\n docs\n\n// comment") } @(test) @@ -413,7 +413,7 @@ ast_hover_proc_with_proc_parameter :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.aa: proc(p: proc())") + test.expect_hover(t, &source, "test.aa :: proc(p: proc())") } @(test) @@ -424,7 +424,7 @@ ast_hover_proc_with_proc_parameter_with_return :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.aa: proc(p: proc() -> int)") + test.expect_hover(t, &source, "test.aa :: proc(p: proc() -> int)") } @(test) @@ -523,7 +523,7 @@ ast_hover_struct :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\t// this is a doc\n\tbar: int,\n\tf: proc(a: int) -> int,\n}", + "test.Foo :: struct {\n\t// this is a doc\n\tbar: int,\n\tf: proc(a: int) -> int,\n}", ) } @@ -554,7 +554,7 @@ ast_hover_proc_param_with_struct_from_another_package :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.My_Struct: struct {\n\tone: int,\n\ttwo: int,\n\tthree: int,\n}") + test.expect_hover(t, &source, "my_package.My_Struct :: struct {\n\tone: int,\n\ttwo: int,\n\tthree: int,\n}") } @(test) @@ -586,7 +586,7 @@ ast_hover_enum :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Foo: enum {\n\tFoo1,\n\tFoo2,\n}") + test.expect_hover(t, &source, "test.Foo :: enum {\n\tFoo1,\n\tFoo2,\n}") } @(test) @@ -618,7 +618,7 @@ ast_hover_union :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Foo: union {\n\tstring,\n\tint,\n}") + test.expect_hover(t, &source, "test.Foo :: union {\n\tstring,\n\tint,\n}") } @(test) @@ -697,7 +697,7 @@ ast_hover_within_struct_declaration :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.get_int: proc() -> int") + test.expect_hover(t, &source, "test.get_int :: proc() -> int") } @(test) @@ -733,7 +733,7 @@ ast_hover_proc_overloading :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.foo: proc(i: int, j: int, allocator := context.allocator) -> (_: int, _: bool)", + "test.foo :: proc(i: int, j: int, allocator := context.allocator) -> (_: int, _: bool)", ) } @@ -767,7 +767,7 @@ ast_hover_proc_overloading_no_params :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.foo: proc(allocator := context.allocator) -> (_: int, _: bool)") + test.expect_hover(t, &source, "test.foo :: proc(allocator := context.allocator) -> (_: int, _: bool)") } @(test) @@ -800,7 +800,7 @@ ast_hover_proc_overloading_named_arguments :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.foo: proc(i: int, s := \"hello\") -> (_: int, _: bool)") + test.expect_hover(t, &source, "test.foo :: proc(i: int, s := \"hello\") -> (_: int, _: bool)") } @(test) @@ -847,7 +847,7 @@ ast_hover_proc_overloading_in_package :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "my_package.foo: proc(i: int, allocator := context.allocator, loc := #caller_location) -> (_: int, _: bool)", + "my_package.foo :: proc(i: int, allocator := context.allocator, loc := #caller_location) -> (_: int, _: bool)", ) } @@ -920,7 +920,7 @@ ast_hover_proc_overload_definition :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.foo: proc {\n\tfoo_none :: proc(allocator := context.allocator) -> (_: int, _: bool),\n\tfoo_int :: proc(i: int, allocator := context.allocator) -> (_: int, _: bool),\n}", + "test.foo :: proc {\n\tfoo_none :: proc(allocator := context.allocator) -> (_: int, _: bool),\n\tfoo_int :: proc(i: int, allocator := context.allocator) -> (_: int, _: bool),\n}", ) } @@ -1018,7 +1018,7 @@ ast_hover_empty_line_at_top_of_file :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Foo: struct {\n\tbar: int,\n}") + test.expect_hover(t, &source, "test.Foo :: struct {\n\tbar: int,\n}") } @(test) @@ -1044,7 +1044,7 @@ ast_hover_proc_overloading_arg_with_selector_expr :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.foo: proc(i: int)") + test.expect_hover(t, &source, "test.foo :: proc(i: int)") } @(test) @@ -1085,7 +1085,7 @@ ast_hover_proc_overloading_named_arg_with_selector_expr_with_another_package :: packages = packages[:], } - test.expect_hover(t, &source, "my_package.foo: proc(x := 1) -> (_: int, _: bool)\n Docs\n\n// comment") + test.expect_hover(t, &source, "my_package.foo :: proc(x := 1) -> (_: int, _: bool)\n Docs\n\n// comment") } @(test) @@ -1135,7 +1135,7 @@ ast_hover_proc_overloading_named_arg_with_selector_expr_multiple_packages :: pro packages = packages[:], } - test.expect_hover(t, &source, "my_package.foo: proc(x := 1) -> (_: int, _: bool)") + test.expect_hover(t, &source, "my_package.foo :: proc(x := 1) -> (_: int, _: bool)") } @(test) @@ -1169,7 +1169,7 @@ ast_hover_distinguish_symbols_in_packages_proc :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.foo: proc(x := 1) -> (_: int, _: bool)") + test.expect_hover(t, &source, "my_package.foo :: proc(x := 1) -> (_: int, _: bool)") } @(test) @@ -1200,7 +1200,7 @@ ast_hover_distinguish_symbols_in_packages_struct :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.Foo: struct {\n\tfoo: string,\n}") + test.expect_hover(t, &source, "my_package.Foo :: struct {\n\tfoo: string,\n}") } @(test) @@ -1232,7 +1232,7 @@ ast_hover_distinguish_symbols_in_packages_local_struct :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.Foo: struct {\n\tfoo: string,\n}") + test.expect_hover(t, &source, "my_package.Foo :: struct {\n\tfoo: string,\n}") } @(test) @@ -1379,7 +1379,7 @@ ast_hover_struct_documentation :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\t// This is an int\n\tfoo_int: int,\n\tbar: int, // this is bar\n\tbazz: int,\n}", + "test.Foo :: struct {\n\t// This is an int\n\tfoo_int: int,\n\tbar: int, // this is bar\n\tbazz: int,\n}", ) } @@ -1412,7 +1412,7 @@ ast_hover_struct_documentation_using :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Bazz: struct {\n\tusing bar: Bar,\n\n\t// from `using bar: Bar`\n\t// using a foo\n\tusing foo: Foo, // hi\n\t// this is a string\n\tbar_string: string,\n\tbar_int: int, // This is a bar int\n\n\t// from `using foo: Foo`\n\t// This is an int\n\tfoo_int: int,\n\tfoo_string: string,\n}", + "test.Bazz :: struct {\n\tusing bar: Bar,\n\n\t// from `using bar: Bar`\n\t// using a foo\n\tusing foo: Foo, // hi\n\t// this is a string\n\tbar_string: string,\n\tbar_int: int, // This is a bar int\n\n\t// from `using foo: Foo`\n\t// This is an int\n\tfoo_int: int,\n\tfoo_string: string,\n}", ) } @@ -1459,7 +1459,7 @@ ast_hover_struct_documentation_using_package :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tusing outer: my_package.Outer,\n\n\t// from `using outer: my_package.Outer`\n\t// Inner doc\n\tusing inner: Inner,\n\n\t// from `using inner: Inner`\n\tusing ii: InnerInner, // InnerInner comment\n\n\t// from `using ii: InnerInner`\n\tfield: int,\n}", + "test.Foo :: struct {\n\tusing outer: my_package.Outer,\n\n\t// from `using outer: my_package.Outer`\n\t// Inner doc\n\tusing inner: Inner,\n\n\t// from `using inner: Inner`\n\tusing ii: InnerInner, // InnerInner comment\n\n\t// from `using ii: InnerInner`\n\tfield: int,\n}", ) } @@ -1480,7 +1480,7 @@ ast_hover_proc_comments :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.foo: proc()\n doc\n\n// do foo") + test.expect_hover(t, &source, "test.foo :: proc()\n doc\n\n// do foo") } @(test) @@ -1508,7 +1508,7 @@ ast_hover_proc_comments_package :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.foo: proc()\n// do foo") + test.expect_hover(t, &source, "my_package.foo :: proc()\n// do foo") } @(test) @@ -1559,7 +1559,7 @@ ast_hover_distinct_definition :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.A: distinct u64") + test.expect_hover(t, &source, "test.A :: distinct u64") } @(test) @@ -1581,7 +1581,7 @@ ast_hover_distinct_definition_external_package :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.A: distinct u64") + test.expect_hover(t, &source, "my_package.A :: distinct u64") } @(test) @@ -1723,7 +1723,7 @@ ast_hover_struct_poly_type :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Foo: struct($T: typeid) {\n\tfoo: T,\n}") + test.expect_hover(t, &source, "test.Foo :: struct($T: typeid) {\n\tfoo: T,\n}") } @(test) @@ -1861,7 +1861,7 @@ ast_hover_poly_struct_poly_proc_fields :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct($S: typeid, $T: typeid) {\n\tmy_proc1: proc(s: S) -> ^S,\n\tmy_proc2: proc(t: ^T) -> T,\n\tmy_proc3: proc(s: ^S, t: T) -> T,\n\tmy_proc4: proc() -> T,\n\tmy_proc5: proc(t: T),\n\tfoo1: T,\n\tfoo2: ^S,\n}", + "test.Foo :: struct($S: typeid, $T: typeid) {\n\tmy_proc1: proc(s: S) -> ^S,\n\tmy_proc2: proc(t: ^T) -> T,\n\tmy_proc3: proc(s: ^S, t: T) -> T,\n\tmy_proc4: proc() -> T,\n\tmy_proc5: proc(t: T),\n\tfoo1: T,\n\tfoo2: ^S,\n}", ) } @@ -1898,7 +1898,7 @@ ast_hover_poly_struct_poly_proc_fields_resolved :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct(Bar, my_package.Bazz) {\n\tmy_proc1: proc(s: Bar) -> ^Bar,\n\tmy_proc2: proc(t: my_package.Bazz) -> my_package.Bazz,\n\tmy_proc3: proc(s: ^my_package.Bazz, t: my_package.Bazz) -> my_package.Bazz,\n\tfoo1: my_package.Bazz,\n\tfoo2: ^Bar,\n}", + "test.Foo :: struct(Bar, my_package.Bazz) {\n\tmy_proc1: proc(s: Bar) -> ^Bar,\n\tmy_proc2: proc(t: my_package.Bazz) -> my_package.Bazz,\n\tmy_proc3: proc(s: ^my_package.Bazz, t: my_package.Bazz) -> my_package.Bazz,\n\tfoo1: my_package.Bazz,\n\tfoo2: ^Bar,\n}", ) } @@ -2012,7 +2012,7 @@ ast_hover_enum_defintion_with_base_type :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: enum u8 {\n\tA = 1,\n\tBar = 2,\n\tC = 3,\n}") + test.expect_hover(t, &source, "test.Foo :: enum u8 {\n\tA = 1,\n\tBar = 2,\n\tC = 3,\n}") } @(test) @@ -2025,7 +2025,7 @@ ast_hover_bit_field :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: bit_field u8 {\n\tfoo_a: uint | 2,\n\tfoo_aa: uint | 4,\n}") + test.expect_hover(t, &source, "test.Foo :: bit_field u8 {\n\tfoo_a: uint | 2,\n\tfoo_aa: uint | 4,\n}") } @(test) @@ -2038,7 +2038,7 @@ ast_hover_bit_field_array_backed :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: bit_field [4]u8 {\n\tfoo_a: uint | 1,\n\tfoo_aa: uint | 3,\n}") + test.expect_hover(t, &source, "test.Foo :: bit_field [4]u8 {\n\tfoo_a: uint | 1,\n\tfoo_aa: uint | 3,\n}") } @(test) @@ -2057,7 +2057,7 @@ ast_hover_bit_field_with_docs :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: bit_field u8 {\n\t// documentation\n\tfoo_a: uintptr | 2,\n\tfoo_bbbb: uint | 4, // comment for b\n\t// doc\n\tfoo_c: uint | 2, //comment\n}", + "test.Foo :: bit_field u8 {\n\t// documentation\n\tfoo_a: uintptr | 2,\n\tfoo_bbbb: uint | 4, // comment for b\n\t// doc\n\tfoo_c: uint | 2, //comment\n}", ) } @@ -2081,7 +2081,7 @@ ast_hover_struct_with_bit_field_using :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Bar: struct {\n\tusing foo: Foo,\n\tbar: int,\n\n\t// from `using foo: Foo (bit_field u8)`\n\tfoo_a: uint | 2, // foo_a\n\t// foo_aa\n\tfoo_aa: uint | 4,\n}", + "test.Bar :: struct {\n\tusing foo: Foo,\n\tbar: int,\n\n\t// from `using foo: Foo (bit_field u8)`\n\tfoo_a: uint | 2, // foo_a\n\t// foo_aa\n\tfoo_aa: uint | 4,\n}", ) } @@ -2122,7 +2122,7 @@ ast_hover_struct_with_bit_field_using_across_packages :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Bar: struct {\n\tusing foo: my_package.Foo,\n\tusing bazz: Bazz,\n\tbar: int,\n\n\t// from `using foo: my_package.Foo (bit_field u8)`\n\tfoo_a: uint | 1, // foo_a\n\t// foo_aa\n\tfoo_aa: uint | 7,\n\n\t// from `using bazz: Bazz`\n\tbazz: string, // string for bazz\n}", + "test.Bar :: struct {\n\tusing foo: my_package.Foo,\n\tusing bazz: Bazz,\n\tbar: int,\n\n\t// from `using foo: my_package.Foo (bit_field u8)`\n\tfoo_a: uint | 1, // foo_a\n\t// foo_aa\n\tfoo_aa: uint | 7,\n\n\t// from `using bazz: Bazz`\n\tbazz: string, // string for bazz\n}", ) } @@ -2246,7 +2246,7 @@ ast_hover_enumerated_array_value :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Bar: struct {\n\tbar: int,\n}") + test.expect_hover(t, &source, "test.Bar :: struct {\n\tbar: int,\n}") } @(test) @@ -2335,7 +2335,7 @@ ast_hover_overload_proc_strings_from_different_packages :: proc(t: ^testing.T) { `, packages = packages[:], } - test.expect_hover(t, &source, "my_package.foo: proc(a: string, b: int)") + test.expect_hover(t, &source, "my_package.foo :: proc(a: string, b: int)") } @(test) @@ -2691,7 +2691,7 @@ ast_hover_overloading_with_union :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.my_overload: proc(fb: FooBar)") + test.expect_hover(t, &source, "test.my_overload :: proc(fb: FooBar)") } @(test) @@ -2725,7 +2725,7 @@ ast_hover_overloading_with_union_and_variant :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.my_overload: proc(bar: Bar)") + test.expect_hover(t, &source, "test.my_overload :: proc(bar: Bar)") } @(test) @@ -2763,7 +2763,7 @@ ast_hover_overloading_struct_with_usings :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foobar: proc(b: Bar)") + test.expect_hover(t, &source, "test.foobar :: proc(b: Bar)") } @(test) @@ -2801,7 +2801,7 @@ ast_hover_overloading_struct_with_usings_with_pointers :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foobar: proc(b: ^Bar)") + test.expect_hover(t, &source, "test.foobar :: proc(b: ^Bar)") } @(test) @@ -2811,7 +2811,7 @@ ast_hover_proc_calling_convention :: proc(t: ^testing.T) { f{*}oo :: proc "contextless" (a: int) {} `, } - test.expect_hover(t, &source, "test.foo: proc \"contextless\" (a: int)") + test.expect_hover(t, &source, "test.foo :: proc \"contextless\" (a: int)") } @(test) @@ -2821,7 +2821,7 @@ ast_hover_proc_directives :: proc(t: ^testing.T) { f{*}oo :: proc(a: int) #no_bounds_check {} `, } - test.expect_hover(t, &source, "test.foo: proc(a: int) #no_bounds_check") + test.expect_hover(t, &source, "test.foo :: proc(a: int) #no_bounds_check") } @(test) @@ -2833,7 +2833,7 @@ ast_hover_proc_attributes :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "@(require_results)\ntest.foo: proc(a: int) -> int") + test.expect_hover(t, &source, "@(require_results)\ntest.foo :: proc(a: int) -> int") } @(test) @@ -2845,7 +2845,7 @@ ast_hover_proc_attributes_key_value :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "@(disabled=false)\ntest.foo: proc(a: int) -> int") + test.expect_hover(t, &source, "@(disabled=false)\ntest.foo :: proc(a: int) -> int") } @(test) @@ -2857,7 +2857,7 @@ ast_hover_proc_force_inline :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: #force_inline proc(a: int) -> int") + test.expect_hover(t, &source, "test.foo :: #force_inline proc(a: int) -> int") } @(test) @@ -2873,7 +2873,7 @@ ast_hover_proc_force_no_inline :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: #force_no_inline proc(a: int) -> int") + test.expect_hover(t, &source, "test.foo :: #force_no_inline proc(a: int) -> int") } @(test) @@ -2885,7 +2885,7 @@ ast_hover_builtin_max_with_type_local :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.max_u32: u32") + test.expect_hover(t, &source, "test.max_u32 :: u32") } @(test) @@ -2895,7 +2895,7 @@ ast_hover_builtin_max_with_type_global :: proc(t: ^testing.T) { ma{*}x_u32 :: max(u32) `, } - test.expect_hover(t, &source, "test.max_u32: u32") + test.expect_hover(t, &source, "test.max_u32 :: u32") } @(test) @@ -2905,7 +2905,7 @@ ast_hover_builtin_max_ints :: proc(t: ^testing.T) { ma{*}x_int :: max(1, 2, 3, 4) `, } - test.expect_hover(t, &source, "test.max_int: int") + test.expect_hover(t, &source, "test.max_int :: 4") } @(test) @@ -2931,7 +2931,7 @@ ast_hover_builtin_max_mix_const :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.m: float") + test.expect_hover(t, &source, "test.m :: 4.6") } @(test) @@ -2941,7 +2941,7 @@ ast_hover_builtin_max_mix_global_const :: proc(t: ^testing.T) { m{*} :: max(1, 2.0, 3, 4.6) `, } - test.expect_hover(t, &source, "test.m: float") + test.expect_hover(t, &source, "test.m :: 4.6") } @(test) @@ -3192,7 +3192,7 @@ ast_hover_documentation_reexported :: proc(t: ^testing.T) { `, packages = packages[:], } - test.expect_hover(t, &source, "my_package.Foo: struct {}\n Documentation for Foo") + test.expect_hover(t, &source, "my_package.Foo :: struct {}\n Documentation for Foo") } @(test) @@ -3218,7 +3218,7 @@ ast_hover_override_documentation_reexported :: proc(t: ^testing.T) { `, packages = packages[:], } - test.expect_hover(t, &source, "my_package.Foo: struct {}\n New docs for Foo") + test.expect_hover(t, &source, "my_package.Foo :: struct {}\n New docs for Foo") } @(test) @@ -3463,7 +3463,7 @@ ast_hover_enum_field_documentation :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: enum {\n\tA = 1, // this is a comment for A\n\t// This is a doc for B\n\t// across many lines\n\tB,\n\tC,\n\t// D Doc\n\tD,\n\tE, // E comment\n}", + "test.Foo :: enum {\n\tA = 1, // this is a comment for A\n\t// This is a doc for B\n\t// across many lines\n\tB,\n\tC,\n\t// D Doc\n\tD,\n\tE, // E comment\n}", ) } @@ -3481,7 +3481,7 @@ ast_hover_enum_field_documentation_same_line :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: enum {\n\t// Doc for A and B\n\t// Mulitple lines!\n\tA, // comment for A and B\n\t// Doc for A and B\n\t// Mulitple lines!\n\tB, // comment for A and B\n}", + "test.Foo :: enum {\n\t// Doc for A and B\n\t// Mulitple lines!\n\tA, // comment for A and B\n\t// Doc for A and B\n\t// Mulitple lines!\n\tB, // comment for A and B\n}", ) } @@ -3518,7 +3518,7 @@ ast_hover_union_field_documentation :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: union {\n\tint, // this is a comment for int\n\t// This is a doc for string\n\t// across many lines\n\tstring,\n\ti16,\n\t// i32 Doc\n\ti32,\n\ti64, // i64 comment\n}", + "test.Foo :: union {\n\tint, // this is a comment for int\n\t// This is a doc for string\n\t// across many lines\n\tstring,\n\ti16,\n\t// i32 Doc\n\ti32,\n\ti64, // i64 comment\n}", ) } @@ -3536,7 +3536,7 @@ ast_hover_union_field_documentation_same_line :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: union {\n\t// Doc for int and string\n\t// Mulitple lines!\n\tint, // comment for int and string\n\t// Doc for int and string\n\t// Mulitple lines!\n\tstring, // comment for int and string\n}", + "test.Foo :: union {\n\t// Doc for int and string\n\t// Mulitple lines!\n\tint, // comment for int and string\n\t// Doc for int and string\n\t// Mulitple lines!\n\tstring, // comment for int and string\n}", ) } @@ -3599,7 +3599,7 @@ ast_hover_union_with_tag :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.Foo: union #no_nil {\n\tint,\n\tstring,\n}") + test.expect_hover(t, &source, "test.Foo :: union #no_nil {\n\tint,\n\tstring,\n}") } @(test) @@ -3611,7 +3611,7 @@ ast_hover_union_with_align :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: union #no_nil #align(4) {\n\tint,\n\tstring,\n}") + test.expect_hover(t, &source, "test.Foo :: union #no_nil #align(4) {\n\tint,\n\tstring,\n}") } @(test) @@ -3686,7 +3686,7 @@ ast_hover_nested_struct :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tfoo: int,\n\tbar: struct {\n\t\ti: int,\n\t\ts: string,\n\t},\n}", + "test.Foo :: struct {\n\tfoo: int,\n\tbar: struct {\n\t\ti: int,\n\t\ts: string,\n\t},\n}", ) } @@ -3706,7 +3706,7 @@ ast_hover_nested_struct_union :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tfoo: int,\n\tbar: union #no_nil {\n\t\tint, // int comment\n\t\tstring,\n\t},\n}", + "test.Foo :: struct {\n\tfoo: int,\n\tbar: union #no_nil {\n\t\tint, // int comment\n\t\tstring,\n\t},\n}", ) } @@ -3727,7 +3727,7 @@ ast_hover_nested_struct_enum :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tfoo: int,\n\tbar: enum {\n\t// A doc\n\t\tA,\n\t\tB,\n\t},\n}", + "test.Foo :: struct {\n\tfoo: int,\n\tbar: enum {\n\t// A doc\n\t\tA,\n\t\tB,\n\t},\n}", ) } @@ -3748,7 +3748,7 @@ ast_hover_nested_struct_bit_field :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tfoo: int,\n\tbar: bit_field u8 {\n\t// A doc\n\t\ta: uint | 3,\n\t\tb: uint | 5,\n\t},\n}", + "test.Foo :: struct {\n\tfoo: int,\n\tbar: bit_field u8 {\n\t// A doc\n\t\ta: uint | 3,\n\t\tb: uint | 5,\n\t},\n}", ) } @@ -3766,7 +3766,7 @@ ast_hover_foreign_block_calling_convention :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, `test.foo: proc "c" () -> int`) + test.expect_hover(t, &source, `test.foo :: proc "c" () -> int`) } @(test) @@ -3783,7 +3783,7 @@ ast_hover_foreign_block_calling_convention_overridden :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, `test.foo: proc "contextless" () -> int`) + test.expect_hover(t, &source, `test.foo :: proc "contextless" () -> int`) } @(test) @@ -3800,7 +3800,7 @@ ast_hover_foreign_block_link_prefix :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, "@(link_prefix=\"bar\")\ntest.foo: proc() -> int") + test.expect_hover(t, &source, "@(link_prefix=\"bar\")\ntest.foo :: proc() -> int") } @(test) @@ -3817,7 +3817,7 @@ ast_hover_foreign_block_link_prefix_overridden :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, "@(link_name=\"foreign_foo\")\ntest.foo: proc() -> int") + test.expect_hover(t, &source, "@(link_name=\"foreign_foo\")\ntest.foo :: proc() -> int") } @(test) @@ -3834,7 +3834,7 @@ ast_hover_foreign_private_block :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, "@(private)\ntest.foo: proc() -> int") + test.expect_hover(t, &source, "@(private)\ntest.foo :: proc() -> int") } @(test) @@ -3851,7 +3851,7 @@ ast_hover_foreign_private_block_overridden :: proc(t: ^testing.T) { fo{*}o `, } - test.expect_hover(t, &source, "@(private=\"file\")\ntest.foo: proc() -> int") + test.expect_hover(t, &source, "@(private=\"file\")\ntest.foo :: proc() -> int") } @(test) @@ -3932,7 +3932,7 @@ ast_hover_struct_container_fields :: proc(t: ^testing.T) { test.expect_hover( t, &source, - "test.Foo: struct {\n\tfoo_slice: []int,\n\tfoo_dynamic: [dynamic]int,\n\tfoo_array: [5]int,\n\tfoo_map: map[int]int,\n\tfoo_matrix: matrix[3,4]int,\n}", + "test.Foo :: struct {\n\tfoo_slice: []int,\n\tfoo_dynamic: [dynamic]int,\n\tfoo_array: [5]int,\n\tfoo_map: map[int]int,\n\tfoo_matrix: matrix[3,4]int,\n}", ) } @@ -3945,7 +3945,7 @@ ast_hover_struct_field_proc_calling_convention :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct {\n\tfoo_proc: proc \"c\" (a: int, b: int) -> int,\n}") + test.expect_hover(t, &source, "test.Foo :: struct {\n\tfoo_proc: proc \"c\" (a: int, b: int) -> int,\n}") } @(test) @@ -3955,7 +3955,7 @@ ast_hover_distinct_array :: proc(t: ^testing.T) { F{*}oo :: distinct [4]u8 `, } - test.expect_hover(t, &source, "test.Foo: distinct [4]u8") + test.expect_hover(t, &source, "test.Foo :: distinct [4]u8") } @(test) @@ -3966,7 +3966,7 @@ ast_hover_struct_tags :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct #raw_union #no_copy {}") + test.expect_hover(t, &source, "test.Foo :: struct #raw_union #no_copy {}") } @(test) @@ -3977,7 +3977,7 @@ ast_hover_struct_tags_packed :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct($T: typeid) #packed {}") + test.expect_hover(t, &source, "test.Foo :: struct($T: typeid) #packed {}") } @(test) @@ -3988,7 +3988,7 @@ ast_hover_struct_tags_align :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct($T: typeid) #align(4) {}") + test.expect_hover(t, &source, "test.Foo :: struct($T: typeid) #align(4) {}") } @(test) @@ -4016,7 +4016,7 @@ ast_hover_struct_tags_align_package :: proc(t: ^testing.T) { packages = packages[:], } - test.expect_hover(t, &source, "my_package.Foo: struct(int) #align(4) {}") + test.expect_hover(t, &source, "my_package.Foo :: struct(int) #align(4) {}") } @(test) @@ -4028,7 +4028,7 @@ ast_hover_struct_tags_field_align :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct #max_field_align(4) #min_field_align(2) {}") + test.expect_hover(t, &source, "test.Foo :: struct #max_field_align(4) #min_field_align(2) {}") } @(test) @@ -4060,7 +4060,7 @@ ast_hover_struct_with_soa_field :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Bar: struct {\n\tfoos: #soa[5]Foo,\n}") + test.expect_hover(t, &source, "test.Bar :: struct {\n\tfoos: #soa[5]Foo,\n}") } @(test) @@ -4159,7 +4159,7 @@ ast_hover_proc_within_for_loop :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: proc()") + test.expect_hover(t, &source, "test.foo :: proc()") } @(test) @@ -4247,7 +4247,7 @@ ast_hover_binary_expr_with_type :: proc(t: ^testing.T) { F{*}OO :: 1 + u8(2) `, } - test.expect_hover(t, &source, "test.FOO: u8") + test.expect_hover(t, &source, "test.FOO :: u8") } @(test) @@ -4298,7 +4298,7 @@ ast_hover_overload_private_procs :: proc(t: ^testing.T) { `, packages = packages[:], } - test.expect_hover(t, &source, "@(private=\"file\")\nmy_package.foo: proc(s: string)") + test.expect_hover(t, &source, "@(private=\"file\")\nmy_package.foo :: proc(s: string)") } @(test) @@ -4322,7 +4322,7 @@ ast_hover_ternary :: proc(t: ^testing.T) { fo{*}o :: true ? 1 : 2 `, } - test.expect_hover(t, &source, "test.foo: int") + test.expect_hover(t, &source, "test.foo :: 1") } @(test) @@ -4392,7 +4392,7 @@ ast_hover_basic_value_cast_from_package :: proc(t: ^testing.T) { @(test) ast_hover_parapoly_elem_overloaded_proc :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test foo :: proc { foo_array, @@ -4408,13 +4408,13 @@ ast_hover_parapoly_elem_overloaded_proc :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: proc(i: int)") + test.expect_hover(t, &source, "test.foo :: proc(i: int)") } @(test) ast_hover_parapoly_elem_overloaded_proc_multiple_options :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test foo :: proc { foo_array, @@ -4432,13 +4432,13 @@ ast_hover_parapoly_elem_overloaded_proc_multiple_options :: proc(t: ^testing.T) } `, } - test.expect_hover(t, &source, "test.foo: proc {\n\tfoo_int :: proc(i: int),\n\tfoo_string :: proc(s: string),\n}") + test.expect_hover(t, &source, "test.foo :: proc {\n\tfoo_int :: proc(i: int),\n\tfoo_string :: proc(s: string),\n}") } @(test) ast_hover_overloaded_proc_slice_dynamic_array :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test foo :: proc { foo_slice, @@ -4454,13 +4454,13 @@ ast_hover_overloaded_proc_slice_dynamic_array :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: proc(array: $A/[dynamic]$T)") + test.expect_hover(t, &source, "test.foo :: proc(array: $A/[dynamic]$T)") } @(test) ast_hover_proc_call_implicit_selector_with_default_value :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: enum { X, Y, @@ -4487,7 +4487,7 @@ ast_hover_proc_call_implicit_selector_with_default_value :: proc(t: ^testing.T) @(test) ast_hover_casted_variable :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test main :: proc() { foo: int = 25 bar := cast(f32)fo{*}o @@ -4500,7 +4500,7 @@ ast_hover_casted_variable :: proc(t: ^testing.T) { @(test) ast_hover_float_binary_expr :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test main :: proc() { foo := 2.1 b{*}ar := foo - 2 @@ -4513,7 +4513,7 @@ ast_hover_float_binary_expr :: proc(t: ^testing.T) { @(test) ast_hover_parapoly_struct_with_where_clause :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test type_is_integer :: proc($T: typeid) -> bool { return true } @@ -4526,13 +4526,17 @@ ast_hover_parapoly_struct_with_where_clause :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: struct($T: typeid, $N: int) #packed where type_is_integer(T), N > 2 {\n\tx: [N]T,\n\ty: [N - 2]T,\n}") + test.expect_hover( + t, + &source, + "test.Foo :: struct($T: typeid, $N: int) #packed where type_is_integer(T), N > 2 {\n\tx: [N]T,\n\ty: [N - 2]T,\n}", + ) } @(test) ast_hover_parapoly_proc_with_where_clause :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test fo{*}o :: proc(x: [$N]int) -> bool where N > 2 #optional_ok { fmt.println(#procedure, "was called with the parameter", x) @@ -4540,13 +4544,13 @@ ast_hover_parapoly_proc_with_where_clause :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.foo: proc(x: [$N]int) -> bool where N > 2 #optional_ok") + test.expect_hover(t, &source, "test.foo :: proc(x: [$N]int) -> bool where N > 2 #optional_ok") } @(test) ast_hover_parapoly_union_with_where_clause :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test type_is_integer :: proc($T: typeid) -> bool { return true } @@ -4557,25 +4561,25 @@ ast_hover_parapoly_union_with_where_clause :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.Foo: union($T: typeid) #no_nil where type_is_integer(T) {\n\tT,\n\tstring,\n}") + test.expect_hover(t, &source, "test.Foo :: union($T: typeid) #no_nil where type_is_integer(T) {\n\tT,\n\tstring,\n}") } @(test) ast_hover_proc_named_return_parens :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test f{*}oo :: proc() -> (a: int) { return } `, } - test.expect_hover(t, &source, "test.foo: proc() -> (a: int)") + test.expect_hover(t, &source, "test.foo :: proc() -> (a: int)") } @(test) ast_hover_map_value_comp_lit :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { foo: int, } @@ -4594,7 +4598,7 @@ ast_hover_map_value_comp_lit :: proc(t: ^testing.T) { @(test) ast_hover_assign_comp_lit :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { foo: int, } @@ -4613,7 +4617,7 @@ ast_hover_assign_comp_lit :: proc(t: ^testing.T) { @(test) ast_hover_assign_comp_lit_with_multiple_assigns_first :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { a: int, } @@ -4636,7 +4640,7 @@ ast_hover_assign_comp_lit_with_multiple_assigns_first :: proc(t: ^testing.T) { @(test) ast_hover_assign_comp_lit_with_multiple_assigns_second :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { a: int, } @@ -4659,7 +4663,7 @@ ast_hover_assign_comp_lit_with_multiple_assigns_second :: proc(t: ^testing.T) { @(test) ast_hover_comp_lit_map_key :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { a: int, } @@ -4680,7 +4684,7 @@ ast_hover_comp_lit_map_key :: proc(t: ^testing.T) { @(test) ast_hover_inner_struct_field :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { a: int, b: struct { @@ -4695,7 +4699,7 @@ ast_hover_inner_struct_field :: proc(t: ^testing.T) { @(test) ast_hover_using_bit_field_struct :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: struct { a: int, using _: bit_field u8 { @@ -4710,7 +4714,7 @@ ast_hover_using_bit_field_struct :: proc(t: ^testing.T) { @(test) ast_hover_proc_group_parapoly_matrix :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test mul :: proc { matrix_mul, @@ -4742,7 +4746,7 @@ ast_hover_proc_group_parapoly_matrix :: proc(t: ^testing.T) { @(test) ast_hover_proc_group_variadic_args :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test append_elems :: proc(array: ^$T/[dynamic]string, args: ..string) {} append_elem :: proc(array: ^$T/[dynamic]string, arg: string) {} @@ -4758,13 +4762,13 @@ ast_hover_proc_group_variadic_args :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.append: proc(array: ^$T/[dynamic]string, args: ..string)") + test.expect_hover(t, &source, "test.append :: proc(array: ^$T/[dynamic]string, args: ..string)") } @(test) ast_hover_proc_group_variadic_args_with_generic_type :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test append_elems :: proc(array: ^$T/[dynamic]$E, args: ..E) {} append_elem :: proc(array: ^$T/[dynamic]$E, arg: E) {} @@ -4780,13 +4784,13 @@ ast_hover_proc_group_variadic_args_with_generic_type :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.append: proc(array: ^$T/[dynamic]$E, args: ..E)") + test.expect_hover(t, &source, "test.append :: proc(array: ^$T/[dynamic]$E, args: ..E)") } @(test) ast_hover_proc_group_with_generic_type_from_proc_param :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test append_elems :: proc(array: ^$T/[dynamic]$E, args: ..E) {} append_elem :: proc(array: ^$T/[dynamic]$E, arg: E) {} @@ -4800,13 +4804,13 @@ ast_hover_proc_group_with_generic_type_from_proc_param :: proc(t: ^testing.T) { } `, } - test.expect_hover(t, &source, "test.append: proc(array: ^$T/[dynamic]$E, arg: E)") + test.expect_hover(t, &source, "test.append :: proc(array: ^$T/[dynamic]$E, arg: E)") } @(test) ast_hover_enum_implicit_if_statement :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test Foo :: enum { A, B, @@ -4825,7 +4829,7 @@ ast_hover_enum_implicit_if_statement :: proc(t: ^testing.T) { @(test) ast_hover_if_ternary_expr :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test main :: proc() { foo: []int ba{*}r := len(foo) if true else 2 @@ -4838,11 +4842,11 @@ ast_hover_if_ternary_expr :: proc(t: ^testing.T) { @(test) ast_hover_proc_param_tags :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test f{*}oo :: proc (#by_ptr a: int, #any_int b: int) {} `, } - test.expect_hover(t, &source, "test.foo: proc(#by_ptr a: int, #any_int b: int)") + test.expect_hover(t, &source, "test.foo :: proc(#by_ptr a: int, #any_int b: int)") } @(test) @@ -4868,7 +4872,7 @@ ast_hover_simd_array_pointer :: proc(t: ^testing.T) { @(test) ast_hover_const_untyped_value :: proc(t: ^testing.T) { source := test.Source { - main = `package test + main = `package test F{*}OO :: 123 `, } diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index a7ad3cf..1485731 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -22,7 +22,7 @@ ast_declare_proc_signature :: proc(t: ^testing.T) { ast_naked_parens :: proc(t: ^testing.T) { source := test.Source { main = `package test - main :: proc() { + main :: proc() { if node == nil { return; @@ -47,7 +47,7 @@ ast_simple_proc_signature :: proc(t: ^testing.T) { cool_function :: proc(a: int) { } - main :: proc() { + main :: proc() { cool_function({*}) } `, @@ -57,7 +57,7 @@ ast_simple_proc_signature :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.cool_function: proc(a: int)"}, + {"test.cool_function :: proc(a: int)"}, ) } @@ -68,7 +68,7 @@ ast_default_assignment_proc_signature :: proc(t: ^testing.T) { cool_function :: proc(a: int, b := context.allocator) { } - main :: proc() { + main :: proc() { cool_function({*}) } `, @@ -78,7 +78,7 @@ ast_default_assignment_proc_signature :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.cool_function: proc(a: int, b := context.allocator)"}, + {"test.cool_function :: proc(a: int, b := context.allocator)"}, ) } @@ -89,7 +89,7 @@ ast_proc_signature_argument_last_position :: proc(t: ^testing.T) { cool_function :: proc(a: int, b: int) { } - main :: proc() { + main :: proc() { cool_function(2,{*} } `, @@ -106,7 +106,7 @@ ast_proc_signature_argument_first_position :: proc(t: ^testing.T) { cool_function :: proc(a: int, b: int) { } - main :: proc() { + main :: proc() { cool_function(2{*},) } `, @@ -124,7 +124,7 @@ ast_proc_signature_argument_move_position :: proc(t: ^testing.T) { cool_function :: proc(a: int, b: int, c: int) { } - main :: proc() { + main :: proc() { cool_function(2,3{*}, 3); } `, @@ -141,7 +141,7 @@ ast_proc_signature_argument_complex :: proc(t: ^testing.T) { cool_function :: proc(a: int, b: int, c: int) { } - main :: proc() { + main :: proc() { cool_function(a(2,5,b(3,sdf[2],{})), {*}); } `, @@ -158,7 +158,7 @@ ast_proc_signature_argument_open_brace_position :: proc(t: ^testing.T) { cool_function :: proc(a: int, b: int, c: int) { } - main :: proc() { + main :: proc() { cool_function(2,3, 3{*} } `, @@ -175,7 +175,7 @@ ast_proc_signature_argument_any_ellipsis_position :: proc(t: ^testing.T) { cool_function :: proc(args: ..any, b := 2) { } - main :: proc() { + main :: proc() { cool_function(3, 4, 5{*}) } `, @@ -211,8 +211,8 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) { t, &source, { - "test.int_function: proc(a: int)", - "test.bool_function: proc(a: bool)", + "test.int_function :: proc(a: int)", + "test.bool_function :: proc(a: bool)", }, ) } @@ -226,7 +226,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) { clone_array :: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A { } - + main :: proc() { clone_array({*}) } @@ -238,7 +238,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) { t, &source, { - "test.clone_array: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A", + "test.clone_array :: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A", }, ) } @@ -268,7 +268,7 @@ ast_proc_group_signature_basic_types :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.int_function: proc(a: int, b: bool, c: int)"}, + {"test.int_function :: proc(a: int, b: bool, c: int)"}, ) } @@ -304,7 +304,7 @@ ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.distinct_function: proc(a: My_Int, c: int)"}, + {"test.distinct_function :: proc(a: My_Int, c: int)"}, ) } @@ -348,7 +348,7 @@ ast_proc_group_signature_struct :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.struct_function: proc(a: int, b: My_Struct, c: int)"}, + {"test.struct_function :: proc(a: int, b: My_Struct, c: int)"}, ) } @@ -383,7 +383,7 @@ index_simple_signature :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"my_package.my_function: proc(a: int, b := context.allocator)"}, + {"my_package.my_function :: proc(a: int, b := context.allocator)"}, ) } @@ -401,7 +401,7 @@ ast_index_builtin_len_proc :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"len: proc(array: Array_Type) -> int"}, + {"len :: proc(array: Array_Type) -> int"}, ) } @@ -437,7 +437,7 @@ ast_signature_variable_pointer :: proc(t: ^testing.T) { packages = {}, } - test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"}) + test.expect_signature_labels(t, &source, {"test.My_Fun :: proc(a: int)"}) } @@ -459,7 +459,7 @@ ast_signature_global_variable_pointer :: proc(t: ^testing.T) { packages = {}, } - test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"}) + test.expect_signature_labels(t, &source, {"test.My_Fun :: proc(a: int)"}) } @(test) @@ -493,7 +493,7 @@ index_variable_pointer_signature :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"my_package.My_Fun: proc(a: int)"}, + {"my_package.My_Fun :: proc(a: int)"}, ) } @@ -516,7 +516,7 @@ shared_value_decl_type_signature :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.my_function: proc(a: int, b: int)"}, + {"test.my_function :: proc(a: int, b: int)"}, ) } @@ -538,7 +538,7 @@ proc_with_struct_poly :: proc(t: ^testing.T) { packages = {}, } - test.expect_signature_labels(t, &source, {"test.uf: proc(u: U($T, $E))"}) + test.expect_signature_labels(t, &source, {"test.uf :: proc(u: U($T, $E))"}) } @(test) @@ -558,7 +558,7 @@ proc_signature_move_outside :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - {"test.my_cool_function: proc(aa: int, ba: int, c: int)"}, + {"test.my_cool_function :: proc(aa: int, ba: int, c: int)"}, ) } -- cgit v1.2.3