[SourceKit] DocInfo: For synthesized extension, update their extended fields to the synthesized target instead of their original extended types. rdar://25439820

This commit is contained in:
Xi Ge
2016-03-31 17:50:06 -07:00
parent 16a23d79b4
commit 126bc4e942
3 changed files with 68 additions and 62 deletions

View File

@@ -438,13 +438,17 @@ static void passExtends(const ValueDecl *D, DocInfoConsumer &Consumer) {
static void reportRelated(ASTContext &Ctx,
const Decl *D,
const Decl* SynthesizedTarget,
DocInfoConsumer &Consumer) {
if (!D || isa<ParamDecl>(D))
return;
if (const ExtensionDecl *ED = dyn_cast<ExtensionDecl>(D)) {
if (Type T = ED->getExtendedType())
if (SynthesizedTarget) {
passExtends((ValueDecl*)SynthesizedTarget, Consumer);
} else if (Type T = ED->getExtendedType()) {
if (auto TD = getTypeDeclFromType(T))
passExtends(TD, Consumer);
}
passInherits(ED->getInherited(), Consumer);
@@ -525,7 +529,9 @@ static void reportDocEntities(ASTContext &Ctx,
if (initDocEntityInfo(Entity, EntInfo))
continue;
Consumer.startSourceEntity(EntInfo);
reportRelated(Ctx, Entity.Dcl, Consumer);
reportRelated(Ctx, Entity.Dcl,
Entity.IsSynthesizedExtension ? Entity.SynthesizeTarget : nullptr,
Consumer);
reportDocEntities(Ctx, Entity.SubEntities, Consumer);
reportAttributes(Ctx, Entity.Dcl, Consumer);
Consumer.finishSourceEntity(EntInfo.Kind);