Skip to content
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

Introduce FixIt.Change API that replaces the child of a syntax node #2205

Closed
ahoppen opened this issue Sep 16, 2023 · 6 comments · Fixed by #2758
Closed

Introduce FixIt.Change API that replaces the child of a syntax node #2205

ahoppen opened this issue Sep 16, 2023 · 6 comments · Fixed by #2758
Assignees
Labels
enhancement New feature or request

Comments

@ahoppen
Copy link
Member

ahoppen commented Sep 16, 2023

Currently, Fix-Its are only able to replace syntax nodes but that makes it impossible to replace a nil node by a proper syntax node.

We should offer a FixIt.Change that replaces the child of a syntax node, with a signature that’s something like this (written in GitHub, not sure if it compiles, but it gets the idea across).

FixIt.Change.replaceChild<Parent, Child>(_: KeyPath<Parent, Child>, of parent: Parent, with: Child)

FixItApplier will need to be updated to also handle this new change kind

rdar://115562892

@ahoppen ahoppen added the enhancement New feature or request label Sep 16, 2023
@mininny
Copy link
Contributor

mininny commented Oct 6, 2023

I'd like to have a go at this if it's okay!

@kimdv
Copy link
Contributor

kimdv commented Oct 6, 2023

@mininny it now yours :D

@AppAppWorks
Copy link
Contributor

@ahoppen, I wanted to tackle this issue but apparently there's no way to make WritableKeyPath conform with Sendable 🤷‍♂️

@ahoppen
Copy link
Member Author

ahoppen commented Jul 22, 2024

You should be able to always use WritableKeyPath & Sendable, similar to

case layout([AnyKeyPath & Sendable])

@AppAppWorks
Copy link
Contributor

What could be the use cases for replaceChild?

@j-f1
Copy link
Contributor

j-f1 commented Jul 27, 2024

One use case (that I ran into recently) is adding a return type to a function declaration that doesn’t have one. Or potentially appending/removing a parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants