Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Unregistering syntax via
SyntaxRegistry#unregister
will often fail silently. The issue was caused by the comparator used inSyntaxRegister
not enforcing a consistent order for uniqueSyntaxInfo
s. Currently, elements are ordered first byPriority
. Within the group of elements that share a Priority, it is ordered by registration-order (that is, which one was registered first). This ordering is random and not derived from any properties of the SyntaxInfos themselves. Thus, if I register some SyntaxInfo "A" and then register a whole bunch more, there is no guarantee that a call likeregister.contains(A)
will be successful (it may not reach "A" due to the underlying data structure used).Solution
The issue is resolved by enforcing a consistent ordering. That is, there will always be a consistent ordering for any collection of SyntaxInfos. This means it is no longer safe to simply change registration order to fix conflicts. Of course, this was never safe, and one should instead use Priorities - they are designed for this issue! This consistency accomplished by using hashcodes for ordering SyntaxInfos that share a priority.
Testing Completed
A new JUnit test was introduced in
SyntaxRegistryTest
.Supporting Information
n/a
Completes: none
Related: none