@@ -2064,7 +2064,21 @@ namespace {
2064
2064
printCommonPost (PD);
2065
2065
}
2066
2066
2067
- void printGenericParameters (GenericParamList *Params) {
2067
+ void printGenericSignature (const GenericSignature &Sig, Label label) {
2068
+ if (!Sig)
2069
+ return ;
2070
+
2071
+ printRecArbitrary ([&](Label label) {
2072
+ printHead (" generic_signature" , ASTNodeColor, label);
2073
+ printList (Sig.getGenericParams (), [&](auto GP, Label label) {
2074
+ printTypeField (GP, label);
2075
+ }, Label::always (" generic_params" ));
2076
+ printGenericRequirements (Sig.getRequirements ());
2077
+ printFoot ();
2078
+ }, label);
2079
+ }
2080
+
2081
+ void printParsedGenericParams (GenericParamList *Params) {
2068
2082
if (!Params)
2069
2083
return ;
2070
2084
@@ -2101,20 +2115,13 @@ namespace {
2101
2115
printCommon ((Decl*)VD, Name, label, Color);
2102
2116
2103
2117
printDeclName (VD, Label::optional (" name" ));
2104
- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD)) {
2105
- printGenericParameters (AFD->getParsedGenericParams ());
2106
- if (AFD->hasComputedGenericSignature ())
2107
- printGenericRequirements (AFD->getGenericRequirements ());
2108
- }
2109
- if (auto *GTD = dyn_cast<GenericTypeDecl>(VD)) {
2110
- printGenericParameters (GTD->getParsedGenericParams ());
2111
- if (GTD->hasComputedGenericSignature ())
2112
- printGenericRequirements (GTD->getGenericRequirements ());
2113
- }
2114
- if (auto *MD = dyn_cast<MacroDecl>(VD)) {
2115
- printGenericParameters (MD->getParsedGenericParams ());
2116
- if (MD->hasComputedGenericSignature ())
2117
- printGenericRequirements (MD->getGenericRequirements ());
2118
+ if (auto *GC = VD->getAsGenericContext ()) {
2119
+ if (Writer.isParsable () && GC->hasComputedGenericSignature ()) {
2120
+ printGenericSignature (GC->getGenericSignature (),
2121
+ Label::optional (" generic_signature" ));
2122
+ } else {
2123
+ printParsedGenericParams (GC->getParsedGenericParams ());
2124
+ }
2118
2125
}
2119
2126
2120
2127
if (VD->hasInterfaceType ()) {
@@ -2277,11 +2284,7 @@ namespace {
2277
2284
}
2278
2285
2279
2286
void printStorageImpl (AbstractStorageDecl *D) {
2280
- // Use a different label for the parsable outputs because "type: true" is
2281
- // confusing, especially when we also have keys elsewhere named "type"
2282
- // that are type USRs.
2283
- printFlag (D->isStatic (), Writer.isParsable () ? " static" : " type" ,
2284
- DeclModifierColor);
2287
+ printFlag (D->isStatic (), " static" , DeclModifierColor);
2285
2288
2286
2289
if (D->hasInterfaceType ()) {
2287
2290
auto impl = D->getImplInfo ();
@@ -2519,10 +2522,7 @@ namespace {
2519
2522
2520
2523
void printCommonFD (FuncDecl *FD, const char *type, Label label) {
2521
2524
printCommonAFD (FD, type, label);
2522
- // Use a different label for the parsable outputs because "type: true" is
2523
- // confusing, especially when we also have keys elsewhere named "type"
2524
- // that are type USRs.
2525
- printFlag (FD->isStatic (), Writer.isParsable () ? " static" : " type" );
2525
+ printFlag (FD->isStatic (), " static" , DeclModifierColor);
2526
2526
}
2527
2527
2528
2528
void visitFuncDecl (FuncDecl *FD, Label label) {
@@ -5316,14 +5316,15 @@ class PrintConformance : public PrintBase {
5316
5316
// parsable (JSON) output because it is far too much information when it is
5317
5317
// rendered as part of every declref that contains such a conformance.
5318
5318
auto shouldPrintDetails =
5319
- visited.insert (conformance).second ; // && !Writer.isParsable();
5319
+ visited.insert (conformance).second && !Writer.isParsable ();
5320
5320
5321
5321
auto printCommon = [&](StringRef kind) {
5322
5322
printHead (kind, ASTNodeColor, label);
5323
5323
printTypeField (conformance->getType (), Label::always (" type" ));
5324
5324
printReferencedDeclField (conformance->getProtocol (),
5325
5325
Label::always (" protocol" ));
5326
- printFlag (!shouldPrintDetails, " <details printed above>" );
5326
+ if (!Writer.isParsable ())
5327
+ printFlag (!shouldPrintDetails, " <details printed above>" );
5327
5328
};
5328
5329
5329
5330
switch (conformance->getKind ()) {
0 commit comments