aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/analysis.odin1
-rw-r--r--src/server/collector.odin2
-rw-r--r--src/server/documentation.odin5
-rw-r--r--src/server/generics.odin5
-rw-r--r--tests/hover_test.odin35
5 files changed, 45 insertions, 3 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 8b736c3..41b2d32 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2338,6 +2338,7 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: Symbol, ok := tr
for type in v.types {
append(&b.types, clone_expr(type, context.temp_allocator, nil))
}
+ b.poly = cast(^ast.Field_List)clone_type(v.poly, context.temp_allocator, nil)
resolve_poly_struct(ast_context, &b, v.poly)
}
diff --git a/src/server/collector.odin b/src/server/collector.odin
index cc72509..4af9d7c 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -162,8 +162,8 @@ collect_struct_fields :: proc(
}
}
+ b.poly = cast(^ast.Field_List)clone_type(struct_type.poly_params, collection.allocator, &collection.unique_strings)
value := to_symbol_struct_value(b)
- value.poly = cast(^ast.Field_List)clone_type(struct_type.poly_params, collection.allocator, &collection.unique_strings)
return value
}
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index 6ec0e07..e68ea1a 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -772,7 +772,10 @@ write_symbol_type_information :: proc(sb: ^strings.Builder, ast_context: ^AstCon
fmt.sbprintf(sb, "%s%s", pointer_prefix, symbol.type_name)
}
- if v, ok := symbol.value.(SymbolUnionValue); ok {
+ #partial switch v in symbol.value {
+ case SymbolUnionValue:
+ write_poly_list(sb, v.poly, v.poly_names)
+ case SymbolStructValue:
write_poly_list(sb, v.poly, v.poly_names)
}
return true
diff --git a/src/server/generics.odin b/src/server/generics.odin
index a629d3e..7eea7a2 100644
--- a/src/server/generics.odin
+++ b/src/server/generics.odin
@@ -676,7 +676,10 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuild
continue
}
- if poly, ok := param.type.derived.(^ast.Typeid_Type); ok {
+ if ident, ok := param.type.derived.(^ast.Ident); ok {
+ poly_map[ident.name] = ast_context.call.args[i]
+ b.poly_names[i] = node_to_string(ast_context.call.args[i])
+ } else if poly, ok := param.type.derived.(^ast.Typeid_Type); ok {
if ident, ok := name.derived.(^ast.Ident); ok {
poly_map[ident.name] = ast_context.call.args[i]
b.poly_names[i] = node_to_string(ast_context.call.args[i])
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index dc23947..6f6a66c 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -1733,6 +1733,41 @@ ast_hover_struct_poly_type :: proc(t: ^testing.T) {
}
@(test)
+ast_hover_struct_poly_type_external_package :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "small_array",
+ source = `package small_array
+
+ Small_Array :: struct($N: int, $T: typeid) where N >= 0 {
+ data: [N]T,
+ len: int,
+ }
+ `,
+ },
+ )
+ source := test.Source {
+ main = `package test
+ import "small_array"
+
+ Foo :: struct {
+ foo: int,
+ }
+
+ MAX :: 4
+
+ fo{*}os: small_array.Small_Array(MAX, Foo)
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_hover(t, &source, "test.foos: small_array.Small_Array(MAX, Foo)")
+}
+
+@(test)
ast_hover_poly_proc_mixed_packages :: proc(t: ^testing.T) {
packages := make([dynamic]test.Package, context.temp_allocator)