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

Allow multiple replacements from a single report? #356

Open
amyreese opened this issue Jul 13, 2023 · 2 comments
Open

Allow multiple replacements from a single report? #356

amyreese opened this issue Jul 13, 2023 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@amyreese
Copy link
Member

As mentioned in #170, it can be useful to provide more than one suggested replacement in a single report, for things like adding imports associated with the primary auto-fix. Currently this requires multiple separate calls to self.report(), each with its own node and replacement, which would then be offered to the user as seemingly-unrelated changes and fixes.

Let’s consider allowing reports to offer multiple fixes that get applied as a single operation.

@amyreese amyreese added the enhancement New feature or request label Jul 13, 2023
@amyreese amyreese added this to the 2.x milestone Jul 17, 2023
@povilasb
Copy link

Any updates on this?
Ideally I'd love to be able to use AddImportsVisitor in fixit :)

@wulfmahn
Copy link

wulfmahn commented Sep 21, 2024

I'm new to libCST and Fixit in general, so I may be doing something wrong, but it seems like even if using multiple report calls currently, that if the top-level Module is modified to add another Import to its body, that FixIt will forego traversing the Module's children since the Module has changes to it (see here). This results in users being prompted for multiple changes for a given file, but only the import change ever gets applied.

Unless there is another way to add the import to global scope without modifying the Module object itself, I think this isn't possible with the current design.

Edit: I see there is a different issue reported for this. Placing link here for others to find. #358

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

No branches or pull requests

3 participants