diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-01 09:29:45 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-01 09:29:45 -0400 |
| commit | 75bc2135dbc17e2770c3ec8e3585d481a0b100bb (patch) | |
| tree | 1633c8d7b7d98eb990c8143f7cffd6c54ec7a957 | |
| parent | 8e6ddab0ed0b17230103d4a4a563c7f6b3b6e775 (diff) | |
As struct poly info to hover information
| -rw-r--r-- | src/server/documentation.odin | 14 | ||||
| -rw-r--r-- | tests/hover_test.odin | 14 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 3be174f..9e23b52 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -274,7 +274,19 @@ write_struct_hover :: proc(ast_context: ^AstContext, sb: ^strings.Builder, v: Sy using_index := -1 - strings.write_string(sb, "struct {\n") + strings.write_string(sb, "struct") + if v.poly != nil { + strings.write_string(sb, "(") + for field in v.poly.list { + for name in field.names { + build_string_node(name, sb, false) + } + strings.write_string(sb, ": ") + build_string_node(field.type, sb, false) + } + strings.write_string(sb, ")") + } + strings.write_string(sb, " {\n") for i in 0 ..< len(v.names) { if i < len(v.from_usings) { if index := v.from_usings[i]; index != using_index { diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 1511af6..b91ed6b 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -1595,6 +1595,7 @@ ast_hover_distinct_definition_external_package :: proc(t: ^testing.T) { test.expect_hover(t, &source, "my_package.A: distinct u64") } + @(test) ast_hover_poly_type :: proc(t: ^testing.T) { source := test.Source { @@ -1723,6 +1724,19 @@ ast_hover_poly_type_external_package_with_external_type :: proc(t: ^testing.T) { test.expect_hover(t, &source, "test.foo: small_array.Foo :: struct {}") } + +@(test) +ast_hover_struct_poly_type :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + F{*}oo :: struct($T: typeid) { + foo: T, + } + `, + } + + test.expect_hover(t, &source, "test.Foo: struct($T: typeid) {\n\tfoo: T,\n}") +} /* Waiting for odin fix |