aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-01-15 18:42:09 +1100
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-01-15 18:42:09 +1100
commit105bc8b8eacd255cc598d251bfe091f7bf169016 (patch)
tree43afd25d366f0f3d4153447c0841c11efa91a00f
parent03d564b758d8c3942bcea7dc1eff6ad8211b71ea (diff)
Correct hover info for indexed soa pointers
-rw-r--r--src/server/analysis.odin35
-rw-r--r--tests/hover_test.odin18
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