aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-05 20:00:56 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-05 20:31:49 -0400
commitb8028bb6a559cf20942703e58ac02ac0e89a46c5 (patch)
tree32f4044b49f561e706f31583d12aa58a796fc604 /src
parenta1692bc64885ae46f50d00c6426eaf1a96f6e4fa (diff)
Correctly resolve implicit selector completions for the enumerated arrays
Diffstat (limited to 'src')
-rw-r--r--src/server/completion.odin64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 5c9b53c..96bacdd 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -744,47 +744,47 @@ get_implicit_completion :: proc(
//value decl infer a : My_Enum = .*
if position_context.value_decl != nil && position_context.value_decl.type != nil {
- enum_value: Maybe(SymbolEnumValue)
- exclude_names := make([dynamic]string, context.temp_allocator)
+ if enum_value, ok := unwrap_enum(ast_context, position_context.value_decl.type); ok {
+ for name in enum_value.names {
+ if position_context.comp_lit != nil && field_exists_in_comp_lit(position_context.comp_lit, name) {
+ continue
+ }
+ item := CompletionItem {
+ label = name,
+ kind = .EnumMember,
+ detail = name,
+ }
+ append(&items, item)
+ }
- if _enum_value, ok := unwrap_enum(ast_context, position_context.value_decl.type); ok {
- enum_value = _enum_value
+ list.items = items[:]
+ return
}
if position_context.comp_lit != nil {
- if symbol, ok := resolve_type_expression(ast_context, position_context.value_decl.type); ok {
+ if symbol, ok := resolve_comp_literal(ast_context, position_context); ok {
if v, ok := symbol.value.(SymbolFixedArrayValue); ok {
- if _enum_value, ok := unwrap_enum(ast_context, v.len); ok {
- enum_value = _enum_value
- }
- }
- }
- for elem in position_context.comp_lit.elems {
- if expr, ok := elem.derived.(^ast.Implicit_Selector_Expr); ok {
- if expr.field.name != "_" {
- append(&exclude_names, expr.field.name)
- }
- }
- }
- }
+ if symbol, ok := resolve_type_expression(ast_context, v.len); ok {
+ if v, ok := symbol.value.(SymbolEnumValue); ok {
+ for name, i in v.names {
+ if field_exists_in_comp_lit(position_context.comp_lit, name) {
+ continue
+ }
- if ev, ok := enum_value.?; ok {
- for name in ev.names {
- if !slice.contains(exclude_names[:], name) {
- if position_context.comp_lit != nil && field_exists_in_comp_lit(position_context.comp_lit, name) {
- continue
- }
- item := CompletionItem {
- label = name,
- kind = .EnumMember,
- detail = name,
+ item := CompletionItem {
+ label = name,
+ detail = name,
+ documentation = symbol.doc,
+ }
+
+ append(&items, item)
+ }
+ list.items = items[:]
+ return
+ }
}
- append(&items, item)
}
}
-
- list.items = items[:]
- return
}
}