fixits: sort them before applying them

An experimental commit introduced a fix-it hint that changes comments
such as "/* empty */" into %empty.  But in some case, because
diagnostics are not necessarily emitted in order, the fixits also come
in disorder, which must never happen, as the fixes are installed in
one pass.

* src/fixits.c (fixits_register): Insert them in order.
This commit is contained in:
Akim Demaille
2019-05-04 17:52:51 +02:00
parent 22a00cfbf2
commit 7aa38561f7

View File

@@ -52,6 +52,11 @@ fixit_new (location const *loc, char const* fix)
return res;
}
static int
fixit_cmp (const fixit *a, const fixit *b)
{
return location_cmp (a->location, b->location);
}
static void
fixit_free (fixit *f)
@@ -85,7 +90,7 @@ fixits_register (location const *loc, char const* fix)
(gl_listelement_dispose_fn) fixit_free,
true);
fixit *f = fixit_new (loc, fix);
gl_list_add_last (fixits, f);
gl_sortedlist_add (fixits, (gl_listelement_compar_fn) fixit_cmp, f);
if (feature_flag & feature_fixit_parsable)
fixit_print (f, stderr);
}