aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/analysis.odin6
-rw-r--r--src/server/hover.odin9
-rw-r--r--tests/hover_test.odin16
3 files changed, 25 insertions, 6 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 3b7b87e..44245e1 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1336,14 +1336,16 @@ resolve_soa_selector_field :: proc(
return {}, false
}
+ ast_context.use_locals = true
if symbol, ok := resolve_type_expression(ast_context, expr); ok {
if v, ok := symbol.value.(SymbolStructValue); ok {
for n, i in v.names {
if n == name {
if .SoaPointer in selector.flags {
if resolved, ok := resolve_type_expression(ast_context, v.types[i]); ok {
- symbol.value = resolved.value
- symbol.pkg = symbol.name
+ resolved.pkg = symbol.name
+ resolved.range = v.ranges[i]
+ return resolved, ok
} else {
return {}, false
}
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 03cdedf..bf64967 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -354,11 +354,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
}
case SymbolSliceValue:
- return get_soa_hover(&ast_context, selector, v.expr, nil, field)
+ return get_soa_field_hover(&ast_context, selector, v.expr, nil, field)
case SymbolDynamicArrayValue:
- return get_soa_hover(&ast_context, selector, v.expr, nil, field)
+ return get_soa_field_hover(&ast_context, selector, v.expr, nil, field)
case SymbolFixedArrayValue:
- return get_soa_hover(&ast_context, selector, v.expr, v.len, field)
+ return get_soa_field_hover(&ast_context, selector, v.expr, v.len, field)
}
} else if position_context.implicit_selector_expr != nil {
implicit_selector := position_context.implicit_selector_expr
@@ -439,7 +439,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
@(private = "file")
-get_soa_hover :: proc(
+get_soa_field_hover :: proc(
ast_context: ^AstContext,
selector: Symbol,
expr: ^ast.Expr,
@@ -457,6 +457,7 @@ get_soa_hover :: proc(
if selector.name != "" {
symbol.pkg = selector.name
}
+ symbol.name = field
build_documentation(ast_context, &symbol, false)
hover: Hover
hover.contents = write_hover_content(ast_context, symbol)
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index ac6b44a..e50c3c2 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -4325,6 +4325,22 @@ ast_hover_binary_expr_with_type :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.FOO: u8")
}
+
+@(test)
+ast_hover_soa_pointer_field_variable :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ main :: proc() {
+ Shape :: struct{a, b:int}
+ ptr: #soa^#soa[]Shape
+
+ a{*} := ptr.a
+ }
+ `,
+ }
+ test.expect_hover(t, &source, "test.a: int")
+}
/*
Waiting for odin fix