sdk
sdk copied to clipboard
Migration tool should support hints that tell it that a given suggestion is bad
In particular this comes up a lot with bad casts as well as types added to the left hand side where they are unnecessary.
It is very common for the tool to suggest such edits, which then have to be reverted manually. There is no hint that can be added to say "don't insert anything here", or to tell it more generally that something it is trying to do is bad.
When doing large migrations in particular, it can be very cumbersome to make sure you found all the places where it was inserting this bad code, because it is generally taking what should be static failures and converting them into runtime cast failures, hiding them from any diagnostic tooling.
cc @jacob314
I think the best solution here would be a general comment such as /*no-edit*/ or something which would tell the tool it isn't allowed to put anything there, even if that leaves a static error on that line.
The web ui would allow you to replace any suggested edit with that comment, which would resolve a large category of issues.
@stereotype441 how hard would adding/*no-edit*/ be to the tool? Is this something that would be fairly straightforward or something that would require major changes?
I think it would be fairly straightforward. We would have to decide whether it means "at this line" or "at this token position", and how it applies to changes that span multiple lines/tokens, but it shouldn't be too hard to figure all that out.
I'll add it to my backlog, but I'm going through my backlog rather slowly these days because of the work I'm doing on fields promotion and patterns. If anyone wants to put time into this I'd be happy to collaborate on the design and do code reviews 😄
Fwiw, while I think the tool should support this I no longer iterate interactively within the tool personally any more, so you don't need to do this on my behalf.
But I do think for users iterating within the tool it would be a great improvement.
As of 1c7fe7196dd7a542f7f91cd6ea2ac81e1a13146c, the null safety migration tool has been removed from active development and retired. No further work on the tool is planned.
If you still need help, or you believe this issue has been closed in error, please feel free to reopen.