Skip to content

Prepare SwiftSyntaxBuilder to be used in Code-Generation #854

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 28, 2022

  • Make all decl, expr, pattern, stmt and type nodes as well as some hand-picked types conform to ExpressibleByStringInterpolation by generating the conformances using gyb
  • Move SyntaxExpressibleByStringInterpolation to SwiftSyntaxBuilder
    • I think creating syntax nodes from string using interpolation is mostly useful in contexts where you’re building syntax trees in the SwiftSyntaxBuilder style and thus these functions should live in SwiftSyntaxBuilder instead of SwiftParser. It also reduces the amount of code we have in SwiftParser
  • Two SwiftSyntaxBuilder adjustments
    • Fix indentation issue if a parsed syntax node with comments is used inside a builder
    • Add calledExpression label to FunctionCallExpr convenience initializer because otherwise initializing a FunctionCallExpr from a string is ambiguous whether it should be parsed or call the string

@ahoppen ahoppen force-pushed the ahoppen/more-string-interpolation-conformances branch from e5aef85 to 2fc256f Compare September 28, 2022 12:28
@ahoppen ahoppen force-pushed the ahoppen/more-string-interpolation-conformances branch from 2fc256f to 8f62467 Compare September 28, 2022 12:39
@ahoppen
Copy link
Member Author

ahoppen commented Sep 28, 2022

@DougGregor Could you review the changes in

  • Parser.swift
  • Patterns.swift
  • gyb_syntax_support
  • SyntaxExpressibleByStringInterpolationConformances.swift.gyb
  • As well as the fact that I’m moving ExpressibleByStringInterpolation to SwiftSyntaxBuilder

@rintaro Could you take a look at

  • RawSyntaxNodeProtocol.swift
  • RawSyntaxNodes.swift.gyb

…lizer

Otherwise initializing a `FunctionCallExpr` from a string is ambiguous whether it should be parsed or call the string
@ahoppen ahoppen force-pushed the ahoppen/more-string-interpolation-conformances branch from e1c4bf2 to e8219b7 Compare September 28, 2022 20:05
@ahoppen
Copy link
Member Author

ahoppen commented Sep 28, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 108a098 into swiftlang:main Sep 29, 2022
@ahoppen ahoppen deleted the ahoppen/more-string-interpolation-conformances branch September 29, 2022 09:54
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.

1 participant