[SymbolGraph] Type subheadings: don't print generics/inheritance

Subheadings for types are treated more as a title element and can't be
overloaded in the same way that other declarations can be. Abridge these
fragments to only contain the keyword and identifier.

rdar://62040714
This commit is contained in:
Ashley Garland
2020-04-20 14:24:45 -07:00
parent 2996e93444
commit 115a8de9ae
4 changed files with 160 additions and 11 deletions

View File

@@ -476,17 +476,22 @@ SymbolGraph::serializeSubheadingDeclarationFragments(StringRef Key,
const Symbol &S,
llvm::json::OStream &OS) {
DeclarationFragmentPrinter Printer(OS, Key);
auto Options = getDeclarationFragmentsPrintOptions();
Options.ArgAndParamPrinting =
PrintOptions::ArgAndParamPrintingMode::ArgumentOnly;
Options.VarInitializers = false;
Options.PrintDefaultArgumentValue = false;
Options.PrintEmptyArgumentNames = false;
Options.PrintOverrideKeyword = false;
if (S.getSynthesizedBaseType()) {
Options.setBaseType(S.getSynthesizedBaseType());
if (const auto *TD = dyn_cast<GenericTypeDecl>(S.getSymbolDecl())) {
Printer.printAbridgedType(TD);
} else {
auto Options = getDeclarationFragmentsPrintOptions();
Options.ArgAndParamPrinting =
PrintOptions::ArgAndParamPrintingMode::ArgumentOnly;
Options.VarInitializers = false;
Options.PrintDefaultArgumentValue = false;
Options.PrintEmptyArgumentNames = false;
Options.PrintOverrideKeyword = false;
if (S.getSynthesizedBaseType()) {
Options.setBaseType(S.getSynthesizedBaseType());
}
S.getSymbolDecl()->print(Printer, Options);
}
S.getSymbolDecl()->print(Printer, Options);
}
void