diff options
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index a863d5c..42bec3e 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1999,6 +1999,66 @@ append_magic_dynamic_array_completion :: proc( append(items, item) } + // This proc is shared between slices and dynamic arrays. + if _, ok := symbol.value.(SymbolDynamicArrayValue); !ok { + return + } + + prefix := "&" + suffix := "" + if symbol.pointers > 0 { + prefix = "" + suffix = common.repeat( + "^", + symbol.pointers - 1, + context.temp_allocator, + ) + } + ptr_symbol_str := fmt.tprint(prefix, symbol_str, suffix, sep = "") + + //pop + { + item := CompletionItem { + label = "pop", + kind = .Function, + detail = "pop", + textEdit = TextEdit { + newText = fmt.tprintf("pop(%v)", ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + additionalTextEdits = additionalTextEdits, + } + + append(items, item) + } + + dynamic_array_builtins := []string { + "append", + "unordered_remove", + "ordered_remove", + "resize", + "reserve", + "shrink", + "inject_at", + "assign_at", + } + + for name in dynamic_array_builtins { + item := CompletionItem { + label = name, + kind = .Snippet, + detail = name, + additionalTextEdits = additionalTextEdits, + textEdit = TextEdit { + newText = fmt.tprintf("%s(%v, $0)", name, ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + insertTextFormat = .Snippet, + InsertTextMode = .adjustIndentation, + } + + append(items, item) + } } append_magic_union_completion :: proc( |