Skip to content

[ASTGen] Add a convenient method to process attribute arguments #77650

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
Nov 16, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Nov 15, 2024

generateWithLabeledExprListArguments(attribute:_:) ensures all the LabeledExprListSyntax arguments are processed in the generator function.

It simplifies:

    guard var args = node.arguments?.as(LabeledExprListSyntax.self)?[...] else {
      self.diagnose(.expectedArgumentsForAttribtue(node))
      return nil
    }
    
    ...consume arguments...   

    if !args.isEmpty {
      self.diagnose(.extraneousArgumentsInAttribute(node, args.first!))
    }

into:

    self.generateWithLabeledExprListArguments(attribute: node) { args in
      ...consume arguments...
    }

@rintaro
Copy link
Member Author

rintaro commented Nov 15, 2024

@swift-ci Please smoke test

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Nice

@rintaro rintaro force-pushed the astgen-attrframework branch from f4c7556 to fa20a14 Compare November 15, 2024 21:40
@rintaro
Copy link
Member Author

rintaro commented Nov 15, 2024

@swift-ci Please smoke test

@rintaro rintaro enabled auto-merge November 15, 2024 21:41
@rintaro rintaro force-pushed the astgen-attrframework branch from fa20a14 to 5e6904f Compare November 15, 2024 23:45
@rintaro
Copy link
Member Author

rintaro commented Nov 15, 2024

@swift-ci Please smoke test

@rintaro rintaro merged commit 1016971 into swiftlang:main Nov 16, 2024
3 checks passed
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.

3 participants