aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-07-31 19:38:33 +0200
committerGitHub <noreply@github.com>2024-07-31 19:38:33 +0200
commitbf97dfbc6f660b52957e965ce4b80ddeba405b2b (patch)
tree7947be9d82e382132a697c558fba7b49b3a908cc
parent120a1d9e98ca96466e94937faf4b34f352782262 (diff)
parentbc26ac3fd1cf2df7df93a04346c7157fccdbaa3e (diff)
Merge pull request #455 from thetarnav/array-infer-length-hover
Add missing op token when building string for unary expr node
-rw-r--r--src/common/ast.odin1
-rw-r--r--src/server/clone.odin6
-rw-r--r--tests/hover_test.odin22
3 files changed, 29 insertions, 0 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index 267c84d..6e71f60 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -1086,6 +1086,7 @@ build_string_node :: proc(
case ^Tag_Expr:
build_string(n.expr, builder, remove_pointers)
case ^Unary_Expr:
+ strings.write_string(builder, n.op.text)
build_string(n.expr, builder, remove_pointers)
case ^Binary_Expr:
build_string(n.left, builder, remove_pointers)
diff --git a/src/server/clone.odin b/src/server/clone.odin
index 2057c98..507e753 100644
--- a/src/server/clone.odin
+++ b/src/server/clone.odin
@@ -180,7 +180,13 @@ clone_node :: proc(
case ^Tag_Expr:
r.expr = clone_type(r.expr, allocator, unique_strings)
case ^Unary_Expr:
+ n := node.derived.(^Unary_Expr)
r.expr = clone_type(r.expr, allocator, unique_strings)
+ if unique_strings == nil {
+ r.op.text = strings.clone(n.op.text, allocator)
+ } else {
+ r.op.text = get_index_unique_string(unique_strings, allocator, n.op.text)
+ }
case ^Binary_Expr:
n := node.derived.(^Binary_Expr)
r.left = clone_type(r.left, allocator, unique_strings)
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index f74f02a..dfd78f0 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -171,6 +171,28 @@ ast_hover_on_sliced_result :: proc(t: ^testing.T) {
test.expect_hover(t, &source, "test.slice: []byte")
}
+@(test)
+ast_hover_on_array_variable :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ Vec :: [2]f32
+ vec: Ve{*}c
+ `,
+ }
+
+ test.expect_hover(t, &source, "test.Vec: [2]f32")
+}
+
+@(test)
+ast_hover_on_array_infer_length_variable :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ ve{*}c :: [?]f32{1, 2, 3}
+ `,
+ }
+
+ test.expect_hover(t, &source, "test.vec: [?]f32")
+}
@(test)
ast_hover_on_bitset_variable :: proc(t: ^testing.T) {