diff options
| author | Nathaniel Saxe <NathanielSaxophone@gmail.com> | 2026-02-04 15:35:08 -0500 |
|---|---|---|
| committer | Nathaniel Saxe <NathanielSaxophone@gmail.com> | 2026-02-04 15:35:08 -0500 |
| commit | 342a0e1a401627d76dbc20d22bf9d0788b3760c2 (patch) | |
| tree | dd9e310d0b82893099a5475bae04761529277240 /src/server/completion.odin | |
| parent | 857cfd03a5d3b66402105fafe0ec262b4cae5186 (diff) | |
qualify union case names with pointer / package when necessary
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 8be6079..a7b1720 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1943,12 +1943,32 @@ get_used_switch_name :: proc(node: ^ast.Expr) -> (string, bool) { return n.name, true case ^ast.Selector_Expr: return n.field.name, true + case ^ast.Implicit_Selector_Expr: + return n.field.name, true case ^ast.Pointer_Type: return get_used_switch_name(n.elem) } return "", false } +//handles pointers / packages +get_qualified_union_case_name :: proc( + symbol: ^Symbol, + ast_context: ^AstContext, + position_context: ^DocumentPositionContext, +) -> string { + if symbol.pkg == ast_context.document_package { + return fmt.aprintf("%v%v", repeat("^", symbol.pointers, context.temp_allocator), symbol.name) + } else { + return fmt.aprintf( + "%v%v.%v", + repeat("^", symbol.pointers, context.temp_allocator), + get_symbol_pkg_name(ast_context, symbol), + symbol.name, + ) + } +} + get_type_switch_completion :: proc( ast_context: ^AstContext, position_context: ^DocumentPositionContext, @@ -1987,19 +2007,8 @@ get_type_switch_completion :: proc( item := CompletionItem { kind = .EnumMember, } - - if symbol.pkg == ast_context.document_package { - item.label = fmt.aprintf("%v%v", repeat("^", symbol.pointers, context.temp_allocator), name) - item.detail = item.label - } else { - item.label = fmt.aprintf( - "%v%v.%v", - repeat("^", symbol.pointers, context.temp_allocator), - get_symbol_pkg_name(ast_context, &symbol), - name, - ) - item.detail = item.label - } + item.label = get_qualified_union_case_name(&symbol, ast_context, position_context) + item.detail = item.label if position_context.implicit_selector_expr != nil { if remove_edit, ok := create_implicit_selector_remove_edit(position_context); ok { item.additionalTextEdits = remove_edit |