Support merging with disassociated source namespace #130
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.
Currently, if a tree has
and you want to merge
cls1NsCName
never finds its way into the tree, as the visit pass doesn't supply ansA
name. Even worse, if you visit withnsC
on the source andnsB
on the destination side, an exception is thrown, since the incoming source namespace (nsC
) doesn't exist in the tree yet.Both of these cases can be solved by iterating all incoming namespaces that actually are present in the tree (
nsB
in this case), searching for entries with the same name (here:cls1NsBName
) and if found, merging the new data into that existing entry, leading to the following result:That's exactly what this PR does, however there's an edge case I wasn't sure how to handle: What if we find a match in more than one namespace, but each one belonging to a different entry?
Tree:
To be merged:
This would match both
cls1
andcls2
. As of now, this PR returns after merging with the first match, but we could of course merge with the remaining matches too or throw an exception instead. What are your opinions on this?