diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-12-30 08:53:11 +1100 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-12-30 08:53:11 +1100 |
| commit | ddc4a61653f0dc620bfa565c598f92b840500a9a (patch) | |
| tree | 34847a691ce312078b7259f4b80f43bf4598a752 | |
| parent | 5872154f56d21074f0e77950612bc769351094aa (diff) | |
Improve bitset completions with proc groups
| -rw-r--r-- | src/server/analysis.odin | 5 | ||||
| -rw-r--r-- | src/server/completion.odin | 5 | ||||
| -rw-r--r-- | tests/completions_test.odin | 25 | ||||
| -rw-r--r-- | tests/hover_test.odin | 26 |
4 files changed, 61 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 2c7f4f4..3ced0ad 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2451,6 +2451,11 @@ resolve_implicit_selector :: proc( if position_context.call != nil { if call, ok := position_context.call.derived.(^ast.Call_Expr); ok { parameter_index, parameter_ok := find_position_in_call_param(position_context, call^) + old := ast_context.resolve_specific_overload + ast_context.resolve_specific_overload = true + defer { + ast_context.resolve_specific_overload = old + } if symbol, ok := resolve_type_expression(ast_context, call.expr); ok && parameter_ok { if proc_value, ok := symbol.value.(SymbolProcedureValue); ok { if len(proc_value.arg_types) <= parameter_index { diff --git a/src/server/completion.odin b/src/server/completion.odin index d80e451..62f0488 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1403,6 +1403,11 @@ get_implicit_completion :: proc( if position_context.call != nil { if call, ok := position_context.call.derived.(^ast.Call_Expr); ok { parameter_index, parameter_ok := find_position_in_call_param(position_context, call^) + old := ast_context.resolve_specific_overload + ast_context.resolve_specific_overload = true + defer { + ast_context.resolve_specific_overload = old + } if symbol, ok := resolve_type_expression(ast_context, call.expr); ok && parameter_ok { set_ast_package_set_scoped(ast_context, symbol.pkg) diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 3c34603..f5d32dc 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -5233,7 +5233,32 @@ ast_completion_proc_arg_default_enum_alias :: proc(t: ^testing.T) { main :: proc() { foo(.{*}) } + `, + } + test.expect_completion_docs(t, &source, "", {"A", "B"}) +} + +@(test) +ast_completion_proc_group_bitset :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + A, + B, + } + + Foos :: bit_set[Foo] + foo_one :: proc(i: int, foos: Foos) {} + foo_two :: proc(s: string, foos: Foos) {} + foo :: proc { + foo_one, + foo_two, + } + + main :: proc() { + foo(1, {.{*}}) + } `, } test.expect_completion_docs(t, &source, "", {"A", "B"}) diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 6f8cecf..8c39b0f 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5960,6 +5960,32 @@ ast_hover_directives_config_info :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "#config(<identifier>, default)\n\nChecks if an identifier is defined through the command line, or gives a default value instead.\n\nValues can be set with the `-define:NAME=VALUE` command line flag.") } + +@(test) +ast_hover_proc_group_bitset :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + A, + B, + } + + Foos :: bit_set[Foo] + + foo_one :: proc(i: int, foos: Foos) {} + foo_two :: proc(s: string, foos: Foos) {} + foo :: proc { + foo_one, + foo_two, + } + + main :: proc() { + foo(1, {.A{*}}) + } + `, + } + test.expect_hover(t, &source, "test.Foo: .A") +} /* Waiting for odin fix |