Edits in assists are prone to panic #14921
Labels
A-assists
C-Architecture
Big architectural things which we need to figure up-front (or suggestions for rewrites :0) )
Immediate problem: In the following code, when the mentioned assist is triggered, all but the last either panic or produce bogus code. The last one had also panicked before #12789.
Code
Problem:
SourceChangeBuilder
is easy to use, but also easy to misuse when the assist operates on self-nestable nodes (e.g. record expressions can be embedded into another record expression) because there is an invariant for the edits: each range of the edits MUST NOT overlap with each other.We can avoid violating the invariant by:
(This is just an example generic procedure that should work for all cases, there may be better/more efficient procedures depending on the assist)
Currently we should implement this for every assist that may operate on overlappable nodes, but manually doing so is extremely error-prone. There should be another API that wraps
SourceChangeBuilder
(or anything needed) and does things correctly without much care from its users.Feel free to change the issue title, I'm obviously not the best person to come up with a good title.
The text was updated successfully, but these errors were encountered: