If a token triggers two rules, which suggestion will be shown to the user? Is it always the first one appearing in grammar.xml?
There’s no defined order. If you want to force an order you can do so in e.g.
German.getPriorityForId() by returning a higher number for the “better” rule.
That’s de jure ordering. (EG: we have no officially defined order for those POSTAG-rules)
What he’s asking about is the de facto ordering. (EG: unless stated otherwise POSTAG-rules are handled based on their file position.)
I don’t know that ordering, you’d need to test it. But I don’t see how it matters, as the behavior can change any time. Actually, depending on the internal data structures, it might even be random.
In computing nothing is truly random, but it might be a good idea to set up some default ordering-rules (to be used when there is no explicit priority).
IMHO the de-facto order in web-interface is reversed (the last rule matched wins), we even adjusted web-extension code to produce the same behavior (as it was reverse): https://github.com/languagetool-org/languagetool-browser-addon/commit/dd766bf181b0f0c7d10c5097856d0eecf134b013
We filter overlapping rules here. If there is no priority established, we choose the match with the longest string. If the lengths are the same, we choose the last one (mimicking the web-interface behavior).
This filter is used in LT server and LibreOffice, but not in LT command-line or LT GUI (because these are testing environments and it is preferable to see all the results).