diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-24 09:10:25 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-24 09:10:25 -0400 |
| commit | 656fbf87d5ae541e409dcbd0906262e3d8f0d881 (patch) | |
| tree | 8f689ce14431ca933c2c3d38afc24cc3c6355d42 /src/server | |
| parent | 9ccd1aa0c7f2ac0d8982750a9ac5c9d5c1e1ea34 (diff) | |
Add completion for passing a dynamic array to a proc that expects a slice
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index a8a2718..e66418b 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -17,15 +17,8 @@ import "core:sort" import "core:strconv" import "core:strings" - import "src:common" -/* - TODOS: Making the signature details is really annoying and not that nice - try to see if this can be refractored. - -*/ - - CompletionResult :: struct { symbol: Symbol, snippet: Snippet_Info, @@ -336,7 +329,7 @@ convert_completion_results :: proc( if config.enable_completion_matching { if s, ok := symbol.(Symbol); ok && (completion_type == .Selector || completion_type == .Identifier) { - handle_pointers(ast_context, position_context, result.symbol, s, &item, completion_type) + handle_matching(ast_context, position_context, result.symbol, s, &item, completion_type) } } @@ -389,7 +382,7 @@ convert_completion_results :: proc( } @(private = "file") -handle_pointers :: proc( +handle_matching :: proc( ast_context: ^AstContext, position_context: ^DocumentPositionContext, result_symbol: Symbol, @@ -414,6 +407,12 @@ handle_pointers :: proc( return false } + if _, ok := arg_symbol.value.(SymbolSliceValue); ok { + if _, ok := result_symbol.value.(SymbolDynamicArrayValue); ok { + return false + } + } + a_id := reflect.union_variant_typeid(arg_symbol.value) b_id := reflect.union_variant_typeid(result_symbol.value) @@ -437,9 +436,16 @@ handle_pointers :: proc( return } - diff := result_symbol.pointers - arg_symbol.pointers suffix := "" prefix := "" + + if _, ok := arg_symbol.value.(SymbolSliceValue); ok { + if _, ok := result_symbol.value.(SymbolDynamicArrayValue); ok { + suffix = "[:]" + } + } + + diff := result_symbol.pointers - arg_symbol.pointers if diff > 0 { suffix = repeat("^", diff, context.temp_allocator) } |