ModuelPrinter: Add delineator to mark Decls from a different source file start.

This commit is contained in:
Xi Ge
2016-03-08 11:54:26 -08:00
parent e674e986a2
commit fb05179ed7

View File

@@ -339,6 +339,8 @@ void swift::ide::printSubmoduleInterface(
SwiftDecls.push_back(D);
}
}
llvm::SetVector<Decl*> PrintLineAfter;
if (!GroupNames.empty()) {
assert(SwiftDecls.empty());
for (auto It = FileRangedDecls.begin(); It != FileRangedDecls.end(); ++ It) {
@@ -354,8 +356,20 @@ void swift::ide::printSubmoduleInterface(
for (auto D : DeclsInFile) {
SwiftDecls.push_back(D);
}
PrintLineAfter.insert(DeclsInFile.back());
}
}
if (!PrintLineAfter.empty())
PrintLineAfter.pop_back();
llvm::SmallString<128> DelineatorBuilder;
if (!PrintLineAfter.empty()) {
DelineatorBuilder.append("// MARK: -\n");
DelineatorBuilder.append("// ");
DelineatorBuilder.append(77, '=');
DelineatorBuilder.append(2, '\n');
}
StringRef DelineatorAfterFile = DelineatorBuilder.str();
// Create the missing import decls and add to the collector.
for (auto *SM : NoImportSubModules) {
@@ -514,6 +528,8 @@ void swift::ide::printSubmoduleInterface(
for (auto *D : SwiftDecls) {
if (PrintDecl(D))
Printer << "\n";
if (PrintLineAfter.count(D) != 0)
Printer << DelineatorAfterFile;
}
}
}