mbeddr.mpsutil: add a new language com.mbeddr.mpsutil.collections that provides an nset type #2574
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.
A new language
com.mbeddr.mpsutil.collections
was added that adds support for a set typenset
that use nodes as the values of the set. Equivalence of nodes is checked structurally. The hash code calculation is done for all properties and children and the first level of references. The runtime solution also contains a more general classEquivalenceHashSet
to implement hash sets with arbitraryequals
andhashcode
methods.nset<>
is also compatible withset<node>
and can be used as its type instead.Implementation note: I didn't use the built-in implementation like the matches statement and the StructuralNodeSet from MPS because it deals poorly with copied nodes. For example, a copy of a class sometimes is not structural equal to the class itself: https://youtrack.jetbrains.com/issue/MPS-37894/matches-operation-not-working-for-type-variables