Skip to content

Fix "escaped newline symbol" bug in CodeGeneration module #2468

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

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

RoBo-Inc
Copy link
Contributor

@RoBo-Inc RoBo-Inc commented Feb 4, 2024

I stumbled upon a small bug by accident, and upon investigation, it appeared to have deep roots. Eventually, it warranted its own PR. The bug involved duplicating empty lines in the generated SyntaxTraits file after every // MARK: - without documentation text.

The file is generated based on SyntaxTraitsFile file of CodeGeneration module:

      // MARK: - \(trait.protocolName)

      \(trait.documentation)
      public protocol \(trait.protocolName): SyntaxProtocol\(raw:

In other parts of the module, similar situations are addressed using the "escaped newline" symbol: "". For instance, in the ResultBuilderFile file:

      // MARK: - \(type.resultBuilderType)

      @resultBuilder
      \(node.node.apiAttributes())\
      public struct \(type.resultBuilderType): ListBuilder

So in this PR, I resolve the bug by employing the same approach. This not only enhances the consistency of the codebase but also serves as an elegant solution to the problem itself.
All the changes are confined to the CodeGeneration module and have no impact on the rest of the SwiftSyntax library, making them safe to merge.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Much simpler

@ahoppen
Copy link
Member

ahoppen commented Feb 5, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge February 5, 2024 21:54
@ahoppen ahoppen merged commit f720b72 into swiftlang:main Feb 6, 2024
@RoBo-Inc RoBo-Inc deleted the fix_escaped_newline_symbol_bug branch February 6, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants