[Feature] Resolve positional @feature.index and bare xmi:id URI fragments (#106)#111
Merged
Conversation
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



What
Closes #106. Adds the two EMF URI-fragment-resolution forms that
Resource.GetEObjectdid not previously support:@feature.indexfragments — e.g.#//@eClassifiers.3/@eStructuralFeatures.1. Resolved by structural navigation from the resource root, indexing into the containment feature named by each segment (mirrors EMF'seObjectForURIFragmentSegment). Works same-file and cross-file.xmi:idfragments — a fragment without a leading slash (e.g.#_node), which EMF resolves viagetEObjectByID. Any element carrying anxmi:idis now recorded in a per-resource id→object map duringReadXml, and consulted when the fragment is not a/-rooted path.(The name-based
name.Ndisambiguation form already resolved since #96, since the disambiguated identifier is the cache key.)How
EObject.ReadXmlnow calls a smallRegisterXmiId()after saving attributes: if the element has anxmi:id, it registers itself with the resource. Covers named and unnamed (EGenericType) objects alike.Resourcegains anidToEObjectmap +RegisterEObjectId(first-writer-wins; a duplicatexmi:idis invalid but must not abort the load).Resource.GetEObjecttail is restructured: after the cache and built-in-type lookups miss, it computes the in-document fragment and delegates to a newResolveInDocumentFragment:/-rooted and contains@→ResolveStructuralFragment(positional navigation)./-rooted, no@→ returns null (pure name paths are already covered by the identifier cache).xmi:idlookup.This runs for the owning resource, which is this resource for a same-file positional reference (rewritten to
file.ecore#//@…) and a sibling for cross-file references. It is evaluated before the cross-resource delegation, so it never trips the cycle guard.@featurename to the owning object's containment list (eClassifiers,eSubpackages,eStructuralFeatures,eOperations,eGenericSuperTypes,eLiterals,eParameters,eGenericExceptions,eTypeParameters,eBounds,eAnnotations) and indexes into it.No existing behaviour changes: name-based and file-delegated resolution paths are unchanged; the new paths only fire on fragments that previously returned null.
Tests
New
ECoreNetto.Tests/Resource/PositionalAndIdFragmentTestFixture.cs(6 tests, synthetic models):eTypereferences;GetEObject;xmi:id(including the duplicate-id first-wins case);xmi:id;@segment,@featurewithout index, non-numeric index, missing name path, empty fragment, unknownxmi:id.Full solution builds with 0 warnings; entire suite green (281 tests, +6).
Scope
Splits from #106 as agreed;
EAnnotation.contents(needs a dynamicEObject) remains tracked separately in #109.