mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ModulePrinting: Merge synthesized extensions' bodies if they have the common constraints.
This commit is contained in:
@@ -479,15 +479,22 @@ void swift::ide::printSubmoduleInterface(
|
||||
continue;
|
||||
|
||||
// Print synthesized extensions.
|
||||
SynthesizedExtensionAnalyzer Analyzer(NTD);
|
||||
SynthesizedExtensionAnalyzer Analyzer(NTD, AdjustedOptions);
|
||||
AdjustedOptions.initArchetypeTransformerForSynthesizedExtensions(NTD,
|
||||
&Analyzer);
|
||||
Analyzer.forEachSynthesizedExtension([&](ExtensionDecl *ET){
|
||||
if (!shouldPrint(ET, AdjustedOptions))
|
||||
return;
|
||||
Printer << "\n";
|
||||
ET->print(Printer, AdjustedOptions);
|
||||
Printer << "\n";
|
||||
Analyzer.forEachSynthesizedExtensionMergeGroup(
|
||||
[&](ArrayRef<ExtensionDecl*> Decls){
|
||||
for (auto ET : Decls) {
|
||||
AdjustedOptions.TransformContext->shouldOpenExtension =
|
||||
Decls.front() == ET;
|
||||
AdjustedOptions.TransformContext->shouldCloseExtension =
|
||||
Decls.back() == ET;
|
||||
if (AdjustedOptions.TransformContext->shouldOpenExtension)
|
||||
Printer << "\n";
|
||||
ET->print(Printer, AdjustedOptions);
|
||||
if (AdjustedOptions.TransformContext->shouldCloseExtension)
|
||||
Printer << "\n";
|
||||
}
|
||||
});
|
||||
AdjustedOptions.clearArchetypeTransformerForSynthesizedExtensions();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user