Skip to content

Serialize package and SPI doc comments in swiftsourceinfo #65265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 26, 2023

Conversation

hamishknight
Copy link
Contributor

Requestify raw and brief comment computation, and allow package and SPI doc comments to be serialized in swiftsourceinfo. In the future we may want to emit a separate private swiftdoc for SPI doc comments, but for now we can just include them in the swiftsourceinfo to at least allow them to be picked up for local builds.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

😍

@hamishknight hamishknight force-pushed the whats-up-doc branch 2 times, most recently from 5b453be to a92da15 Compare April 19, 2023 11:04
Comment on lines -139 to -143
if (Optional<std::pair<RawComment, bool>> RC = Context.getRawComment(this)) {
auto P = RC.value();
if (!SerializedOK || P.second)
return P.first;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh, just noticed this predicate was wrong anyway, and allowed us to retrieve a serialized entry from the cache even if !SerializedOK.

@hamishknight hamishknight force-pushed the whats-up-doc branch 2 times, most recently from 30b2bbf to 575ae2b Compare April 21, 2023 10:03
@hamishknight hamishknight requested a review from artemcm as a code owner April 21, 2023 10:03
Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Hamish. Might be good to get a review from @nkcsgexi as well.

Comment on lines +360 to +362
// Skip the decl if it does not have a comment. Note this means
// we'll only serialize "direct" brief comments, but that's okay
// because clients can compute the semantic brief comment themselves.
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems weird that we output the brief comment to me at all. @nkcsgexi do you remember why this is the case?

@bnbarham bnbarham requested a review from nkcsgexi April 25, 2023 20:33
@nkcsgexi
Copy link
Contributor

nkcsgexi commented Apr 25, 2023

oh, this is a great idea to include internal doc comment in the source info file!

It doesn't seem like there's any client that's
actually taking advantage of setting it to `false`,
and its default value of `false` is more likely
than not going to cause clients to accidentally
miss comments that they may want. In fact, this
was exactly the case for code completion's brief
field. Finally, the parameter wasn't even
consistently applied, as we would attempt to
deserialize swiftdoc comments even if it were
`false`.
Turn these ASTContext cached computations into
request evaluator cached computations.
Previously we were using the same set of conditions
for serializing as for swiftdoc, so excluded them.
However it's reasonable to have them in the
swiftsourceinfo.
Match the format of the spi and package variants of
these tests.
If we have both loaded a swiftdoc, and the decl we
have should have had its doc comment serialized into
it, we can check it without needing to fall back
to the swiftsourceinfo.

This requires a couple of refactorings:

- Factoring out the `shouldIncludeDecl` logic
into `getDocCommentSerializationTargetFor` for
determining whether a doc comment should end up
in the swiftdoc or not.
- Factoring out `CommentProviderFinder` for searching
for the doc providing comment decl for brief
comments, in order to allow us to avoid querying
the raw comment when searching for it. This has the
added bonus of meaning we no longer need to fall
back to parsing the raw comment for the brief
comment if the comment is provided by another decl
in the swiftdoc.

This diff is best viewed without whitespace.
Make it clear that we will walk the comment providing
decls if needed.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

Happy to take care of further feedback in a follow-up

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