aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-06 18:27:03 -0400
committerGitHub <noreply@github.com>2025-09-06 18:27:03 -0400
commitd0262987d39741f9774fd7de8d9c4b331308a968 (patch)
treea42d36599908a4d52e7f201686c4b4701a095f40
parentc3110e2561b141dac0f1345d811ab7a54ded0d3b (diff)
parentb227fafa83e2cf06f961534b6b0f512e5354c9db (diff)
Merge pull request #974 from BradLewis/fix/completion-poly-type-narrowing
Add completion for poly type narrowing
-rw-r--r--src/server/completion.odin6
-rw-r--r--tests/completions_test.odin13
2 files changed, 19 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 29ae7bb..732a940 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -1553,6 +1553,12 @@ get_identifier_completion :: proc(
if position_context.identifier != nil {
if ident, ok := position_context.identifier.derived.(^ast.Ident); ok {
lookup_name = ident.name
+ } else if poly, ok := position_context.identifier.derived.(^ast.Poly_Type); ok {
+ if poly.specialization != nil {
+ if ident, ok := poly.specialization.derived.(^ast.Ident); ok {
+ lookup_name = ident.name
+ }
+ }
}
}
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index a19ab22..d6af935 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -4599,3 +4599,16 @@ ast_completion_handle_matching_from_overloaded_proc :: proc(t: ^testing.T) {
}
test.expect_completion_insert_text(t, &source, "", {"&foo"})
}
+
+@(test)
+ast_completion_poly_proc_narrow_type :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Foo :: struct {x, y: i32}
+
+ foo :: proc (a: $T/F{*}) {}
+ `,
+ }
+ test.expect_completion_docs(t, &source, "", {"test.Foo: struct {..}"})
+}