diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-24 14:52:15 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-24 14:52:15 -0400 |
| commit | 50273daf85ec00f429dd61b1f9f196fb5fdc5bb2 (patch) | |
| tree | ad03d0fca253f2348e5e25d869eb9a7578084ca8 | |
| parent | e50bcf94367f594e76628cae8751b6f00911a4b8 (diff) | |
Correct resolving package instead of field when name collides
| -rw-r--r-- | src/server/hover.odin | 4 | ||||
| -rw-r--r-- | tests/hover_test.odin | 37 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin index fe69949..e3f641d 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -290,6 +290,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> ast_context.current_package = selector.pkg + // TODO: Use resolve_selector_expression for this? #partial switch v in selector.value { case SymbolStructValue: for name, i in v.names { @@ -323,7 +324,8 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> } } } - if resolved, ok := resolve_type_identifier(&ast_context, ident^); ok { + + if resolved, ok := resolve_symbol_return(&ast_context, lookup(ident.name, selector.pkg, ast_context.fullpath)); ok { build_documentation(&ast_context, &resolved, false) resolved.name = ident.name diff --git a/tests/hover_test.odin b/tests/hover_test.odin index b2af26a..345e9f9 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5049,6 +5049,43 @@ ast_hover_proc_overload_nil_pointer :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.foo :: proc(s: ^string)") } + +@(test) +ast_hover_package_proc_naming_conflicting_with_another_package :: proc(t: ^testing.T) { + packages := make([dynamic]test.Package, context.temp_allocator) + + append( + &packages, + test.Package { + pkg = "my_package", + source = `package my_package + foo :: proc() {} + `, + }, + ) + append( + &packages, + test.Package { + pkg = "foo", + source = `package foo + `, + }, + ) + + source := test.Source { + main = `package test + import "my_package" + import "foo" + + main :: proc() { + f := my_package.fo{*}o + } + `, + packages = packages[:], + } + + test.expect_hover(t, &source, "my_package.foo :: proc()") +} /* Waiting for odin fix |