From d2a6b208bf6a9d62400b9134f557658ea4ad9b83 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 08:56:27 -0400 Subject: Correctly resolve proc param type --- src/server/analysis.odin | 15 +++++++++++++++ src/server/completion.odin | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/server') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 170bf37..0c3178a 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -659,6 +659,21 @@ get_procedure_arg_count :: proc(v: SymbolProcedureValue) -> int { return total } +// Gets the call argument type at the specified index +get_proc_call_argument_type :: proc(value: SymbolProcedureValue, parameter_index: int) -> (^ast.Field, bool) { + index := 0 + for arg in value.arg_types { + for name in arg.names { + if index == parameter_index { + return arg, true + } + index += 1 + } + } + + return nil, false +} + /* Figure out which function the call expression is using out of the list from proc group */ diff --git a/src/server/completion.odin b/src/server/completion.odin index 2abf3b2..1381967 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1171,11 +1171,12 @@ get_implicit_completion :: proc( } if proc_value, ok := symbol.value.(SymbolProcedureValue); ok { - if len(proc_value.arg_types) <= parameter_index { + arg_type, arg_type_ok := get_proc_call_argument_type(proc_value, parameter_index) + if !arg_type_ok { return } - if enum_value, ok := unwrap_enum(ast_context, proc_value.arg_types[parameter_index].type); ok { + if enum_value, ok := unwrap_enum(ast_context, arg_type.type); ok { for name in enum_value.names { item := CompletionItem { label = name, -- cgit v1.2.3