aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-05 19:44:41 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-05 20:31:43 -0400
commita1692bc64885ae46f50d00c6426eaf1a96f6e4fa (patch)
tree749db06ff709e9809be31f1c2a6d14b2c6284de7 /src
parent58748c93f2eea884034a128105a54c526edc3048 (diff)
Improve resolving enumerated arrays
Diffstat (limited to 'src')
-rw-r--r--src/server/analysis.odin12
-rw-r--r--src/server/completion.odin18
-rw-r--r--src/server/hover.odin1
-rw-r--r--src/testing/testing.odin15
4 files changed, 44 insertions, 2 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 7914d2f..4573f02 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -305,6 +305,10 @@ resolve_type_comp_literal :: proc(
}
}
}
+ } else if s, ok := current_symbol.value.(SymbolFixedArrayValue); ok {
+ if symbol, ok := resolve_type_expression(ast_context, s.expr); ok {
+ return resolve_type_comp_literal(ast_context, position_context, symbol, comp_lit)
+ }
}
}
} else if comp_value, ok := elem.derived.(^ast.Comp_Lit); ok { //indexed
@@ -4016,6 +4020,14 @@ field_exists_in_comp_lit :: proc(comp_lit: ^ast.Comp_Lit, name: string) -> bool
if ident.name == name {
return true
}
+ } else if selector, ok := field.field.derived.(^ast.Implicit_Selector_Expr); ok {
+ if selector.field != nil {
+ if ident, ok := selector.field.derived.(^ast.Ident); ok {
+ if ident.name == name {
+ return true
+ }
+ }
+ }
}
}
} else if selector, ok := elem.derived.(^ast.Implicit_Selector_Expr); ok {
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 53d4fb9..5c9b53c 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -311,6 +311,24 @@ get_comp_lit_completion :: proc(
append(&items, item)
}
}
+ case SymbolFixedArrayValue:
+ 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
+ }
+
+ item := CompletionItem {
+ label = name,
+ detail = fmt.tprintf(".%s", name),
+ documentation = symbol.doc,
+ }
+
+ append(&items, item)
+ }
+ }
+ }
}
}
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 7dd1e51..adf8556 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -414,7 +414,6 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
}
}
-
}
}
return {}, false, true
diff --git a/src/testing/testing.odin b/src/testing/testing.odin
index 78df00e..7242b39 100644
--- a/src/testing/testing.odin
+++ b/src/testing/testing.odin
@@ -201,7 +201,12 @@ expect_completion_labels :: proc(t: ^testing.T, src: ^Source, trigger_character:
}
}
-expect_completion_details :: proc(t: ^testing.T, src: ^Source, trigger_character: string, expect_details: []string) {
+expect_completion_details :: proc(
+ t: ^testing.T, src: ^Source,
+ trigger_character: string,
+ expect_details: []string,
+ expect_excluded: []string = nil,
+) {
setup(src)
defer teardown(src)
@@ -234,6 +239,14 @@ expect_completion_details :: proc(t: ^testing.T, src: ^Source, trigger_character
log.errorf("Expected completion label %v, but received %v", expect_details[i], completion_list.items)
}
}
+
+ for expect_exclude in expect_excluded {
+ for completion in completion_list.items {
+ if expect_exclude == completion.detail {
+ log.errorf("Expected completion label %v to not be included", expect_exclude)
+ }
+ }
+ }
}
expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_string: string) {