Skip to main content

Module fix

Module fix 

Source
Expand description

Selecting and applying the machine-applicable suggestions of a file’s diagnostics — the rule behind the editor’s source.fixAll.bynk (#2100 slice 6) and bynk check --fix (#2642), which share it so the two cannot drift.

DECISION C (#2100): 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.

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.

Structs§

Selection
What select chose: the edits, and the category of each diagnostic whose suggestion contributed at least one.

Functions§

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 errors 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.
lone_fix
The one machine-applicable suggestion error carries, if it carries exactly one. None for no fix, a placeholder fix, or a choice between candidates.
select
edits, also naming the diagnostics the edits came from.