From 105bc8b8eacd255cc598d251bfe091f7bf169016 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Thu, 15 Jan 2026 18:42:09 +1100 Subject: Correct hover info for indexed soa pointers --- src/server/analysis.odin | 35 +++++++++++++++++++++++++++++------ tests/hover_test.odin | 18 ++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 3ced0ad..a4227dc 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1385,10 +1385,14 @@ resolve_call_directive :: proc(ast_context: ^AstContext, call: ^ast.Call_Expr) - if len(call.args) == 1 { ident := new_type(ast.Ident, call.pos, call.end, ast_context.allocator) ident.name = "u8" - value := SymbolSliceValue{ - expr = ident + value := SymbolSliceValue { + expr = ident, + } + symbol := Symbol { + name = "#load", + pkg = ast_context.current_package, + value = value, } - symbol := Symbol{name = "#load", pkg = ast_context.current_package, value = value} return symbol, true } else if len(call.args) == 2 { return resolve_type_expression(ast_context, call.args[1]) @@ -1407,10 +1411,14 @@ resolve_call_directive :: proc(ast_context: ^AstContext, call: ^ast.Call_Expr) - selector := new_type(ast.Selector_Expr, call.pos, call.end, ast_context.allocator) selector.expr = pkg selector.field = field - value := SymbolSliceValue{ - expr = selector + value := SymbolSliceValue { + expr = selector, + } + symbol := Symbol { + name = "#load_directory", + pkg = ast_context.current_package, + value = value, } - symbol := Symbol{name = "#load_directory", pkg = ast_context.current_package, value = value} return symbol, true } @@ -1429,11 +1437,23 @@ resolve_index_expr :: proc(ast_context: ^AstContext, index_expr: ^ast.Index_Expr #partial switch v in indexed.value { case SymbolDynamicArrayValue: + if .Soa in indexed.flags { + indexed.flags |= { .SoaPointer } + return indexed, true + } ok = internal_resolve_type_expression(ast_context, v.expr, &symbol) case SymbolSliceValue: ok = internal_resolve_type_expression(ast_context, v.expr, &symbol) + if .Soa in indexed.flags { + indexed.flags |= { .SoaPointer } + return indexed, true + } case SymbolFixedArrayValue: ok = internal_resolve_type_expression(ast_context, v.expr, &symbol) + if .Soa in indexed.flags { + indexed.flags |= { .SoaPointer } + return indexed, true + } case SymbolMapValue: ok = internal_resolve_type_expression(ast_context, v.value, &symbol) case SymbolMultiPointerValue: @@ -1471,6 +1491,9 @@ resolve_index_expr :: proc(ast_context: ^AstContext, index_expr: ^ast.Index_Expr } symbol.type = indexed.type + if .Soa in indexed.flags { + symbol.flags |= {.SoaPointer} + } return symbol, ok } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 8c39b0f..7cd2b24 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5986,6 +5986,24 @@ ast_hover_proc_group_bitset :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.Foo: .A") } + +@(test) +ast_hover_soa_struct_field_indexed :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: struct{} + + Bar :: struct { + foos: #soa[dynamic]Foo, + } + + bazz :: proc(bar: ^Bar, index: int) { + f{*}oo := &bar.foos[index] + } + `, + } + test.expect_hover(t, &source, "test.foo: #soa^#soa[dynamic]Foo") +} /* Waiting for odin fix -- cgit v1.2.3