diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-10 21:25:19 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-10 21:25:19 -0400 |
| commit | 005d12ec46a5b3e2574133eb913bacd7b34e7383 (patch) | |
| tree | 6a00446bb53532ddc93c743d3245a51caabd2397 /src/server | |
| parent | 90a41ff247b050228e1a6e1a9fe0486948ca6b9e (diff) | |
Add completions for proc params with default values
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 25018df..9430235 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1335,6 +1335,31 @@ get_identifier_completion :: proc( matcher := common.make_fuzzy_matcher(lookup_name) + if position_context.call != nil { + if call_symbol, ok := resolve_type_expression(ast_context, position_context.call); ok { + if value, ok := call_symbol.value.(SymbolProcedureValue); ok { + for arg in value.orig_arg_types { + // For now we just add params with default values, could add everything we more logic in the future + if arg.default_value != nil { + for name in arg.names { + if ident, ok := name.derived.(^ast.Ident); ok { + if symbol, ok := resolve_type_expression(ast_context, arg.default_value); ok { + if score, ok := common.fuzzy_match(matcher, ident.name); ok == 1 { + symbol.type_name = symbol.name + symbol.type_pkg = symbol.pkg + symbol.name = clean_ident(ident.name) + symbol.type = .Field + append(results, CompletionResult{score = score * 1.1, symbol = symbol}) + } + } + } + } + } + } + } + } + } + global: for k, v in ast_context.globals { if position_context.global_lhs_stmt { break |