aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-27 10:55:18 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-27 10:55:18 -0400
commitbc57cc161d1fee05dae837e4334985dd283a03ba (patch)
tree4dbc9928ca074d26cd2a0b52ee1b2f8fe9fb4ff0
parentb9587954c99bb2186deeccb1413f0127241db130 (diff)
Only override docs for re-exported items if there is new documentation on the when doing the export
-rw-r--r--src/server/analysis.odin9
-rw-r--r--tests/hover_test.odin59
2 files changed, 66 insertions, 2 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 6cbc14d..2c14e78 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1855,8 +1855,13 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide
return_symbol.type = .Variable
}
- return_symbol.doc = get_doc(global.docs, ast_context.allocator)
- return_symbol.comment = get_comment(global.comment)
+ if global.docs != nil {
+ return_symbol.doc = get_doc(global.docs, ast_context.allocator)
+ }
+
+ if global.comment != nil {
+ return_symbol.comment = get_comment(global.comment)
+ }
return return_symbol, ok
} else {
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 783d484..06fe3df 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -3042,6 +3042,65 @@ ast_hover_enum_explicit_type :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.Foo: .A")
}
+
+@(test)
+ast_hover_documentation_reexported :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ // Documentation for Foo
+ Foo :: struct{}
+ `,
+ },
+ )
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ F{*}oo :: my_package.Foo
+ `,
+ packages = packages[:],
+ }
+ test.expect_hover(
+ t,
+ &source,
+ "my_package.Foo: struct {}\n Documentation for Foo",
+ )
+}
+
+@(test)
+ast_hover_override_documentation_reexported :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ // Documentation for Foo
+ Foo :: struct{}
+ `,
+ },
+ )
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ // New docs for Foo
+ F{*}oo :: my_package.Foo
+ `,
+ packages = packages[:],
+ }
+ test.expect_hover(
+ t,
+ &source,
+ "my_package.Foo: struct {}\n New docs for Foo",
+ )
+}
/*
Waiting for odin fix