Skip to main content

Module fix_all

Module fix_all 

Source
Expand description

#2100 slice 6: the source.fixAll.bynk code action — apply every machine-applicable diagnostic suggestion in a file as one edit.

DECISION C: only a suggestion marked [Applicability::MachineApplicable] is taken, and only from a diagnostic that carries exactly one such suggestion. A diagnostic offering several (a choice between candidates) needs a human, so it stays an individual quick fix. The suggestions ride on the committed round’s diagnostics, the same ones crate::code_actions::quick_fixes offers one at a time.

Suggestions are taken in diagnostic order. A suggestion whose edits overlap an edit already taken is skipped whole, never applied in part. Two insertions at the same point overlap unless they are identical, so their order never matters. An identical edit is taken once (two diagnostics asking for the same given entry add it once). A skipped suggestion is still a quick fix, and the next fix-all picks it up once the first batch is applied.

The pure computation lives here. The code_action handler adds DECISION B’s safety gate: the combined edit is offered only if the re-analysed project has no diagnostic the round didn’t already have.

Functions§

action
The versioned source.fixAll.bynk action for edits.
apply
The text with edits (sorted, non-overlapping) applied. An edit whose span isn’t a valid range of text, or that overlaps the one before it, is skipped rather than panicking.
edits
Every edit fix-all would apply to text, the file whose diagnostics these are, sorted by position and non-overlapping. Empty when there is nothing to fix. A suggestion with an edit span that isn’t valid for text (out of bounds, reversed, or off a char boundary) is skipped whole.
kind
The source.fixAll.bynk kind.