aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-10-03 22:48:28 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-10-03 22:48:28 +0200
commit866b0ca031d12a4c03d5a62a0e64a8c6bbe05b92 (patch)
treecaf0e00ceb7d2c19a24a088241c38f80338ee7cd /src
parent2e20163b47b8ee60c6f34a58eb5cc937e6be1357 (diff)
Support completion on comp literals for enumerated arrays.
Diffstat (limited to 'src')
-rw-r--r--src/server/completion.odin29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 7dd36cf..f347480 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -834,6 +834,35 @@ get_implicit_completion :: proc(
reset_ast_context(ast_context)
}
+ /*
+ if it's comp literals for enumerated array:
+ asset_paths := [Asset]cstring {
+ .Layer0 = "assets/layer0.png",
+ }
+
+ Right now `core:odin/parser` is not tolerant enough, so I just look at the type and if it's a enumerated array. I can't get the field value is on the left side.
+ */
+ if position_context.comp_lit != nil {
+ if symbol, ok := resolve_type_expression(ast_context, position_context.comp_lit); ok {
+ if symbol_value, ok := symbol.value.(SymbolFixedArrayValue); ok {
+ if enum_value, ok := unwrap_enum(ast_context, symbol_value.len); ok {
+ for enum_name in enum_value.names {
+ item := CompletionItem {
+ label = enum_name,
+ kind = .EnumMember,
+ detail = enum_name,
+ }
+
+ append(&items, item)
+ }
+
+ list.items = items[:]
+ return
+ }
+ }
+ }
+ }
+
//infer bitset and enums based on the identifier comp_lit, i.e. a := My_Struct { my_ident = . }
if position_context.comp_lit != nil {
if position_context.parent_comp_lit.type != nil {