Skip to content

Commit 7da1fc7

Browse files
authored
Merge pull request #72574 from rintaro/6.0-sourcekit-clang-printer-rdar93731287
[6.0][SourceKit] Stop printing normal comments in clang generated interface
2 parents abbeec3 + 0afadf1 commit 7da1fc7

File tree

44 files changed

+3569
-4279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3569
-4279
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ struct PrintOptions {
450450
bool PrintInSILBody = false;
451451

452452
/// Whether to use an empty line to separate two members in a single decl.
453-
bool EmptyLineBetweenMembers = false;
453+
bool EmptyLineBetweenDecls = false;
454454

455455
/// Whether to print empty members of a declaration on a single line, e.g.:
456456
/// ```
@@ -505,9 +505,6 @@ struct PrintOptions {
505505
/// (e.g. the overridden method in the superclass) if such comment is found.
506506
bool PrintDocumentationComments = false;
507507

508-
/// Whether to print regular comments from clang module headers.
509-
bool PrintRegularClangComments = false;
510-
511508
/// When true, printing interface from a source file will print the original
512509
/// source text for applicable declarations, in order to preserve the
513510
/// formatting.
@@ -648,7 +645,6 @@ struct PrintOptions {
648645
result.TypeDefinitions = true;
649646
result.VarInitializers = true;
650647
result.PrintDocumentationComments = true;
651-
result.PrintRegularClangComments = true;
652648
result.PrintLongAttrsOnSeparateLines = true;
653649
result.AlwaysTryPrintParameterLabels = true;
654650
return result;
@@ -699,7 +695,7 @@ struct PrintOptions {
699695
result.SkipUnderscoredStdlibProtocols = true;
700696
result.SkipUnsafeCXXMethods = true;
701697
result.SkipDeinit = true;
702-
result.EmptyLineBetweenMembers = true;
698+
result.EmptyLineBetweenDecls = true;
703699
result.CascadeDocComment = true;
704700
result.ShouldQualifyNestedDeclarations =
705701
QualifyNestedDeclarations::Always;
@@ -762,7 +758,7 @@ struct PrintOptions {
762758
static PrintOptions printSwiftFileInterface(bool printFullConvention) {
763759
PrintOptions result = printInterface(printFullConvention);
764760
result.AccessFilter = AccessLevel::Internal;
765-
result.EmptyLineBetweenMembers = true;
761+
result.EmptyLineBetweenDecls = true;
766762
return result;
767763
}
768764

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
705705
StringRef RawText =
706706
RC->getRawText(ClangContext.getSourceManager()).rtrim("\n\r");
707707
trimLeadingWhitespaceFromLines(RawText, WhitespaceToTrim, Lines);
708+
indent();
708709
bool FirstLine = true;
709710
for (auto Line : Lines) {
710711
if (FirstLine)
@@ -1134,23 +1135,6 @@ class PrintAST : public ASTVisitor<PrintAST> {
11341135
Printer.setSynthesizedTarget(Options.TransformContext->getDecl());
11351136
}
11361137

1137-
// We want to print a newline before doc comments. Swift code already
1138-
// handles this, but we need to insert it for clang doc comments when not
1139-
// printing other clang comments. Do it now so the printDeclPre callback
1140-
// happens after the newline.
1141-
if (Options.PrintDocumentationComments &&
1142-
!Options.PrintRegularClangComments &&
1143-
D->hasClangNode()) {
1144-
auto clangNode = D->getClangNode();
1145-
auto clangDecl = clangNode.getAsDecl();
1146-
if (clangDecl &&
1147-
clangDecl->getASTContext().getRawCommentForAnyRedecl(clangDecl)) {
1148-
Printer.printNewline();
1149-
indent();
1150-
}
1151-
}
1152-
1153-
11541138
Printer.callPrintDeclPre(D, Options.BracketOptions);
11551139

11561140
if (Options.PrintCompatibilityFeatureChecks) {
@@ -2736,7 +2720,7 @@ void PrintAST::printMembers(ArrayRef<Decl *> members, bool needComma,
27362720
if (!member->shouldPrintInContext(Options))
27372721
continue;
27382722

2739-
if (Options.EmptyLineBetweenMembers)
2723+
if (Options.EmptyLineBetweenDecls)
27402724
Printer.printNewline();
27412725
indent();
27422726
visit(member);

lib/IDE/IDETypeChecking.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ PrintOptions PrintOptions::printDocInterface() {
118118
result.ArgAndParamPrinting =
119119
PrintOptions::ArgAndParamPrintingMode::BothAlways;
120120
result.PrintDocumentationComments = false;
121-
result.PrintRegularClangComments = false;
122121
result.PrintFunctionRepresentationAttrs =
123122
PrintOptions::FunctionRepresentationMode::None;
124123
return result;

0 commit comments

Comments
 (0)