also add sourceOrigin for local protocols without docs

This commit is contained in:
Victoria Mitchell
2021-06-07 09:07:28 -06:00
parent 6f53e1dc04
commit 703ebb6861
2 changed files with 30 additions and 3 deletions

View File

@@ -36,6 +36,15 @@ const ValueDecl *getForeignProtocolRequirement(const ValueDecl *VD, const Module
requirements.pop();
}
}
const ValueDecl *getProtocolRequirement(const ValueDecl *VD) {
auto reqs = VD->getSatisfiedProtocolRequirements();
if (!reqs.empty())
return reqs.front();
else
return nullptr;
}
} // end anonymous namespace
void Edge::serialize(llvm::json::OStream &OS) const {
@@ -82,7 +91,6 @@ void Edge::serialize(llvm::json::OStream &OS) const {
if (const auto *ID = Source.getDeclInheritingDocs())
InheritingDecl = ID;
if (!InheritingDecl && Source.getSynthesizedBaseTypeDecl())
InheritingDecl = Source.getSymbolDecl();
@@ -90,7 +98,12 @@ void Edge::serialize(llvm::json::OStream &OS) const {
if (const auto *ID = getForeignProtocolRequirement(Source.getSymbolDecl(), &Graph->M))
InheritingDecl = ID;
}
if (!InheritingDecl) {
if (const auto *ID = getProtocolRequirement(Source.getSymbolDecl()))
InheritingDecl = ID;
}
// If our source symbol is a inheriting decl, write in information about
// where it's inheriting docs from.
if (InheritingDecl) {