Adjust BriefCommentRequest to only query swiftdoc if we have it

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.
This commit is contained in:
Hamish Knight
2023-04-26 12:38:38 +01:00
parent 4606b14fea
commit 95d0ebdb9b
9 changed files with 268 additions and 147 deletions

View File

@@ -1065,6 +1065,10 @@ Optional<CommentInfo> ModuleFile::getCommentForDecl(const Decl *D) const {
return getCommentForDeclByUSR(USRBuffer.str());
}
bool ModuleFile::hasLoadedSwiftDoc() const {
return Core->DeclCommentTable != nullptr;
}
void ModuleFile::collectSerializedSearchPath(
llvm::function_ref<void(StringRef)> callback) const {
for (auto path: Core->SearchPaths) {