-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Adjust newlines between decls #72553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
188f748
to
72d7e8f
Compare
// We want to print a newline before doc comments. Swift code already | ||
// handles this, but we need to insert it for clang doc comments when not | ||
// printing other clang comments. Do it now so the printDeclPre callback | ||
// happens after the newline. | ||
if (Options.PrintDocumentationComments && D->hasClangNode()) { | ||
auto clangNode = D->getClangNode(); | ||
auto clangDecl = clangNode.getAsDecl(); | ||
if (clangDecl && | ||
clangDecl->getASTContext().getRawCommentForAnyRedecl(clangDecl)) { | ||
Printer.printNewline(); | ||
indent(); | ||
} | ||
} | ||
|
||
Printer.callPrintDeclPre(D, Options.BracketOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was leftover from generated interface printing normal comments between decls, which was hooking "PrintDeclPre". Not needed.
if (D->print(Printer, Options)) { | ||
if (Options.BracketOptions.shouldCloseNominal(D)) | ||
Printer << "\n"; | ||
Printer.printNewline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.printNewline()
instead of << "\n"
because that's ASTPrinter
's style.
for (auto CM : ClangModules) { | ||
for (auto DeclAndLoc : ClangDecls[CM.first]) | ||
PrintDecl(DeclAndLoc.first); | ||
if (PrintDecl(DeclAndLoc.first) && Options.EmptyLineBetweenDecls) | ||
Printer.printNewline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change of this PR. Newline after printing a decl just like Swift decls few lines below
if (PrintDecl(D)) | ||
Printer << "\n"; | ||
if (PrintDecl(D) && Options.EmptyLineBetweenDecls) | ||
Printer.printNewline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes swift-ide-test -print-interface
NOT print newlines between top-level decls.
Currently EmptyLineBetweenDecls
(formerly EmptyLineBetweenMembers
) is enabled in generated-interface only.
@swift-ci Please smoke test |
Previously, Clang modules didn't have empty lines between top-level decls. This was inconsistent with Swift module.
72d7e8f
to
7b3738d
Compare
@swift-ci Please smoke test |
Previously, generated interface for Clang modules didn't have empty lines between top-level decls. This was inconsistent with Swift modules.