aboutsummaryrefslogtreecommitdiff
path: root/src/server/completion.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/completion.odin')
-rw-r--r--src/server/completion.odin35
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