diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2026-02-08 12:46:51 +1100 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2026-02-08 12:46:51 +1100 |
| commit | 8f414b2d8a1a79392887d1e188f2bc6814cdf7c1 (patch) | |
| tree | 556bbc68ca2debbff79fd168e04d34a217835d61 /src/server/completion.odin | |
| parent | 187e8033a37207cb38db9453d8e17299227716e7 (diff) | |
Correct union parapoly completion and switch action naming
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index a7b1720..24b86a1 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1957,18 +1957,37 @@ get_qualified_union_case_name :: proc( 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, - ) + sb := strings.builder_make(context.temp_allocator) + pointer_prefix := repeat("^", symbol.pointers, ast_context.allocator) + strings.write_string(&sb, pointer_prefix) + if symbol.pkg != ast_context.document_package { + strings.write_string(&sb, get_symbol_pkg_name(ast_context, symbol)) } + strings.write_string(&sb, symbol.name) + #partial switch v in symbol.value { + case SymbolUnionValue: + write_poly_names(&sb, v.poly_names) + case SymbolStructValue: + write_poly_names(&sb, v.poly_names) + } + + return strings.to_string(sb) } +write_poly_names :: proc(sb: ^strings.Builder, poly_names: []string) { + if len(poly_names) > 0 { + strings.write_string(sb, "(") + for name, i in poly_names { + strings.write_string(sb, name) + if i != len(poly_names) - 1 { + strings.write_string(sb, ", ") + } + } + strings.write_string(sb, ")") + } +} + + get_type_switch_completion :: proc( ast_context: ^AstContext, position_context: ^DocumentPositionContext, |