aboutsummaryrefslogtreecommitdiff
path: root/src/server/completion.odin
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-03-14 21:41:04 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2022-03-14 21:41:04 +0100
commit123783da820cfa5cd2b230dd910e07005f30ebca (patch)
tree487c2d24647bec8f48328f9bb9eeb9ca4149af2c /src/server/completion.odin
parent06562b8ff7d3d4ad3bb22b66eef8c8111fe243da (diff)
Fix union completion with pointers.
Diffstat (limited to 'src/server/completion.odin')
-rw-r--r--src/server/completion.odin23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 8d6d93a..6e67e35 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -363,9 +363,9 @@ get_selector_completion :: proc(ast_context: ^analysis.AstContext, position_cont
}
if symbol.pkg == ast_context.document_package || base == "runtime" {
- item.label = fmt.aprintf("(%v)", common.node_to_string(type))
+ item.label = fmt.aprintf("(%v%v)", common.repeat("^", symbol.pointers, context.temp_allocator), symbol.name)
} else {
- item.label = fmt.aprintf("(%v.%v)", path.base(symbol.pkg, false, context.temp_allocator), common.node_to_string(type))
+ item.label = fmt.aprintf("(%v%v.%v)", common.repeat("^", symbol.pointers, context.temp_allocator), path.base(symbol.pkg, false, context.temp_allocator), symbol.name)
}
append(&items, item)
@@ -1168,23 +1168,20 @@ get_type_switch_completion :: proc(ast_context: ^analysis.AstContext, position_c
if assign, ok := position_context.switch_type_stmt.tag.derived.(^ast.Assign_Stmt); ok && assign.rhs != nil && len(assign.rhs) == 1 {
if union_value, ok := unwrap_union(ast_context, assign.rhs[0]); ok {
for type, i in union_value.types {
- name := common.node_to_string(type)
-
- if name in used_unions {
- continue
- }
-
if symbol, ok := resolve_type_expression(ast_context, union_value.types[i]); ok {
+ name := symbol.name
+ if name in used_unions {
+ continue
+ }
+
item := CompletionItem {
kind = .EnumMember,
}
-
+
if symbol.pkg == ast_context.document_package {
- item.label = fmt.aprintf("%v", common.node_to_string(union_value.types[i]))
- item.detail = item.label
+ item.label = fmt.aprintf("%v%v", common.repeat("^", symbol.pointers, context.temp_allocator), name)
} else {
- item.label = fmt.aprintf("%v.%v", path.base(symbol.pkg, false, context.temp_allocator), name)
- item.detail = item.label
+ item.label = fmt.aprintf("%v%v.%v", common.repeat("^", symbol.pointers, context.temp_allocator), path.base(symbol.pkg, false, context.temp_allocator), name)
}
append(&items, item)