@@ -308,6 +308,10 @@ void swift::ide::printSubmoduleInterface(
308
308
continue ;
309
309
}
310
310
if (FullModuleName.empty ()) {
311
+ // If group name is given and the decl does not belong to the group, skip it.
312
+ if (GroupName && (!D->getGroupName () ||
313
+ D->getGroupName ().getValue () != GroupName.getValue ()))
314
+ continue ;
311
315
// Add Swift decls if we are printing the top-level module.
312
316
SwiftDecls.push_back (D);
313
317
}
@@ -344,9 +348,15 @@ void swift::ide::printSubmoduleInterface(
344
348
});
345
349
346
350
std::sort (SwiftDecls.begin (), SwiftDecls.end (),
347
- [](Decl *LHS, Decl *RHS) -> bool {
351
+ [& ](Decl *LHS, Decl *RHS) -> bool {
348
352
auto *LHSValue = dyn_cast<ValueDecl>(LHS);
349
353
auto *RHSValue = dyn_cast<ValueDecl>(RHS);
354
+
355
+ // If group is specified, we order the decls by their source order.
356
+ if (GroupName && LHS->getSourceOrder () && RHS->getSourceOrder ()) {
357
+ return LHS->getSourceOrder ().getValue () < RHS->getSourceOrder ().getValue ();
358
+ }
359
+
350
360
if (LHSValue && RHSValue) {
351
361
StringRef LHSName = LHSValue->getName ().str ();
352
362
StringRef RHSName = RHSValue->getName ().str ();
@@ -368,10 +378,6 @@ void swift::ide::printSubmoduleInterface(
368
378
369
379
auto PrintDecl = [&](Decl *D) -> bool {
370
380
ASTPrinter &Printer = *PrinterToUse;
371
- if (GroupName && (!D->getGroupName () ||
372
- D->getGroupName ().getValue () != GroupName.getValue ()))
373
- return false ;
374
-
375
381
if (!shouldPrint (D, AdjustedOptions)) {
376
382
Printer.avoidPrintDeclPost (D);
377
383
return false ;
0 commit comments