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
selectchose: 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 oftext, or that overlaps the one before it, is skipped rather than panicking. - edits
- Every edit fix-all would apply to
text, the file whoseerrorsthese are, sorted by position and non-overlapping. Empty when there is nothing to fix. A suggestion with an edit span that isn’t valid fortext(out of bounds, reversed, or off a char boundary) is skipped whole. - lone_
fix - The one machine-applicable suggestion
errorcarries, if it carries exactly one.Nonefor no fix, a placeholder fix, or a choice between candidates. - select
edits, also naming the diagnostics the edits came from.