Skip to content

Conversation

@hnrklssn
Copy link
Member

Swift nodes imported from clang don't have doc comments carried over, but IDEs are clever enough to fetch the comments from the associated clang node. The swift node in the macro expansion from _SwiftifyImport doesn't have a clang node directly associated with it however.

This patch adds the same comment from the clang node to the _SwiftifyImport macro invocation node. Since the macro has access to this node, it can easily copy over its leading trivia.

For now the comment is not altered at all, meaning @param still remains even if the parmeter is removed.

rdar://151346977

@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

1 similar comment
@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but I'm wondering whether it's easy to write a test to make sure that SourceKit picks up the comment attached to the macro-generated overload?

Copy link
Contributor

@delcypher delcypher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. I do have a suggestion about tweaking the doc comment a little though

Copy link
Contributor

@delcypher delcypher May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a comment here that references an issue (or radar) about the fact that@param and might need to be rewritten.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a minor enough potential future QoL improvement that it doesn't warrant polluting the code with discussion around it

@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

@hnrklssn
Copy link
Member Author

This looks good to me, but I'm wondering whether it's easy to write a test to make sure that SourceKit picks up the comment attached to the macro-generated overload?

It was actually easier than I thought! And I was able to verify that adding our custom line comment still is considered part of the same docs even if the rest uses block comments, which simplifies that implementation a lot.

@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

hnrklssn added 5 commits May 17, 2025 20:44
Swift nodes imported from clang don't have doc comments carried over,
but IDEs are clever enough to fetch the comments from the associated
clang node. The swift node in the macro expansion from _SwiftifyImport
doesn't have a clang node directly associated with it however.

This patch adds the same comment from the clang node to the
_SwiftifyImport macro invocation node. Since the macro has access to
this node, it can easily copy over its leading trivia.

For now the comment is not altered at all, meaning @param still remains
even if the parmeter is removed.

rdar://151346977
@hnrklssn hnrklssn force-pushed the swiftify-doccomment branch from 900eb32 to a907481 Compare May 18, 2025 03:54
@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

@hnrklssn
Copy link
Member Author

@swift-ci please smoke test windows

@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

@hnrklssn hnrklssn merged commit 6534b9b into swiftlang:main May 20, 2025
3 checks passed
hnrklssn added a commit to hnrklssn/swift that referenced this pull request May 29, 2025
Swift nodes imported from clang don't have doc comments carried over,
but IDEs are clever enough to fetch the comments from the associated
clang node. The swift node in the macro expansion from _SwiftifyImport
doesn't have a clang node directly associated with it however.

This patch adds the same comment from the clang node to the
_SwiftifyImport macro invocation node. Since the macro has access to
this node, it can easily copy over its leading trivia.

For now the comment is not altered at all, meaning @param still remains
even if the parmeter is removed.

rdar://151346977
(cherry picked from commit 6534b9b)
hnrklssn added a commit that referenced this pull request May 30, 2025
[Swiftify] Copy doc comment from clang node (#81584)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants