aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-11-30 19:51:55 +1100
committerGitHub <noreply@github.com>2025-11-30 19:51:55 +1100
commit0b947ef026af9e41e06ac7790b5c67c29c827dd3 (patch)
treed3be06cbc82983a26c22841f829134d53e3970e9
parent4e59e6d6e90bedc1aec9711a7b04b415faf19b8d (diff)
parent2ed6299c85a7ba42185edcdb23987fe75747062e (diff)
Merge pull request #1195 from BradLewis/fix/propagate-docs-comments-aliases-in-packages
Propagate docs and comments for aliases defined in other packages
-rw-r--r--src/server/analysis.odin6
-rw-r--r--tests/hover_test.odin48
2 files changed, 54 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 80370d9..a6f3a64 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2658,6 +2658,12 @@ resolve_unresolved_symbol :: proc(ast_context: ^AstContext, symbol: ^Symbol) ->
symbol.value = ret.value
symbol.pkg = ret.pkg
symbol.flags |= ret.flags
+ if symbol.doc == "" {
+ symbol.doc = ret.doc
+ }
+ if symbol.comment == "" {
+ symbol.comment = ret.comment
+ }
} else {
return false
}
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index e5e986f..8a54ad4 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -5804,6 +5804,54 @@ ast_hover_nested_proc_docs_spaces :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.foo :: proc()\n\nDocs!\n Docs2\n")
}
+
+@(test)
+ast_hover_propagate_docs_alias_in_package :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(&packages, test.Package{pkg = "my_package", source = `package my_package
+ // Docs!
+ foo :: proc() {} // Comment!
+
+ bar :: foo
+ `})
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ main :: proc() {
+ my_package.ba{*}r()
+ }
+ `,
+ packages = packages[:],
+ }
+ test.expect_hover(t, &source, "my_package.bar :: proc()\n Docs!\n\n// Comment!")
+}
+
+@(test)
+ast_hover_propagate_docs_alias_in_package_override :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(&packages, test.Package{pkg = "my_package", source = `package my_package
+ // Docs!
+ foo :: proc() {} // Comment!
+
+ // Overridden
+ bar :: foo
+ `})
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ main :: proc() {
+ my_package.ba{*}r()
+ }
+ `,
+ packages = packages[:],
+ }
+ test.expect_hover(t, &source, "my_package.bar :: proc()\n Overridden\n\n// Comment!")
+}
+
/*
Waiting for odin fix