@@ -2056,7 +2056,21 @@ namespace {
2056
2056
printCommonPost (PD);
2057
2057
}
2058
2058
2059
- void printGenericParameters (GenericParamList *Params) {
2059
+ void printGenericSignature (const GenericSignature &Sig, Label label) {
2060
+ if (!Sig)
2061
+ return ;
2062
+
2063
+ printRecArbitrary ([&](Label label) {
2064
+ printHead (" generic_signature" , ASTNodeColor, label);
2065
+ printList (Sig.getGenericParams (), [&](auto GP, Label label) {
2066
+ printTypeField (GP, label);
2067
+ }, Label::always (" generic_params" ));
2068
+ printGenericRequirements (Sig.getRequirements ());
2069
+ printFoot ();
2070
+ }, label);
2071
+ }
2072
+
2073
+ void printParsedGenericParams (GenericParamList *Params) {
2060
2074
if (!Params)
2061
2075
return ;
2062
2076
@@ -2093,20 +2107,13 @@ namespace {
2093
2107
printCommon ((Decl*)VD, Name, label, Color);
2094
2108
2095
2109
printDeclName (VD, Label::optional (" name" ));
2096
- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD)) {
2097
- printGenericParameters (AFD->getParsedGenericParams ());
2098
- if (AFD->hasComputedGenericSignature ())
2099
- printGenericRequirements (AFD->getGenericRequirements ());
2100
- }
2101
- if (auto *GTD = dyn_cast<GenericTypeDecl>(VD)) {
2102
- printGenericParameters (GTD->getParsedGenericParams ());
2103
- if (GTD->hasComputedGenericSignature ())
2104
- printGenericRequirements (GTD->getGenericRequirements ());
2105
- }
2106
- if (auto *MD = dyn_cast<MacroDecl>(VD)) {
2107
- printGenericParameters (MD->getParsedGenericParams ());
2108
- if (MD->hasComputedGenericSignature ())
2109
- printGenericRequirements (MD->getGenericRequirements ());
2110
+ if (auto *GC = VD->getAsGenericContext ()) {
2111
+ if (Writer.isParsable () && GC->hasComputedGenericSignature ()) {
2112
+ printGenericSignature (GC->getGenericSignature (),
2113
+ Label::optional (" generic_signature" ));
2114
+ } else {
2115
+ printParsedGenericParams (GC->getParsedGenericParams ());
2116
+ }
2110
2117
}
2111
2118
2112
2119
if (VD->hasInterfaceType ()) {
@@ -2269,11 +2276,7 @@ namespace {
2269
2276
}
2270
2277
2271
2278
void printStorageImpl (AbstractStorageDecl *D) {
2272
- // Use a different label for the parsable outputs because "type: true" is
2273
- // confusing, especially when we also have keys elsewhere named "type"
2274
- // that are type USRs.
2275
- printFlag (D->isStatic (), Writer.isParsable () ? " static" : " type" ,
2276
- DeclModifierColor);
2279
+ printFlag (D->isStatic (), " static" , DeclModifierColor);
2277
2280
2278
2281
if (D->hasInterfaceType ()) {
2279
2282
auto impl = D->getImplInfo ();
@@ -2511,10 +2514,7 @@ namespace {
2511
2514
2512
2515
void printCommonFD (FuncDecl *FD, const char *type, Label label) {
2513
2516
printCommonAFD (FD, type, label);
2514
- // Use a different label for the parsable outputs because "type: true" is
2515
- // confusing, especially when we also have keys elsewhere named "type"
2516
- // that are type USRs.
2517
- printFlag (FD->isStatic (), Writer.isParsable () ? " static" : " type" );
2517
+ printFlag (FD->isStatic (), " static" , DeclModifierColor);
2518
2518
}
2519
2519
2520
2520
void visitFuncDecl (FuncDecl *FD, Label label) {
@@ -5306,14 +5306,15 @@ class PrintConformance : public PrintBase {
5306
5306
// parsable (JSON) output because it is far too much information when it is
5307
5307
// rendered as part of every declref that contains such a conformance.
5308
5308
auto shouldPrintDetails =
5309
- visited.insert (conformance).second ; // && !Writer.isParsable();
5309
+ visited.insert (conformance).second && !Writer.isParsable ();
5310
5310
5311
5311
auto printCommon = [&](StringRef kind) {
5312
5312
printHead (kind, ASTNodeColor, label);
5313
5313
printTypeField (conformance->getType (), Label::always (" type" ));
5314
5314
printReferencedDeclField (conformance->getProtocol (),
5315
5315
Label::always (" protocol" ));
5316
- printFlag (!shouldPrintDetails, " <details printed above>" );
5316
+ if (!Writer.isParsable ())
5317
+ printFlag (!shouldPrintDetails, " <details printed above>" );
5317
5318
};
5318
5319
5319
5320
switch (conformance->getKind ()) {
0 commit comments