[Feature] implement Resource.GetURIFragment(EObject); fixes #76#77
Merged
Conversation
…ect; fixes #76 Return the EObject.Identifier under which the object is cached during load (the name-based Ecore reference that GetEObject resolves), guaranteeing the GetEObject(GetURIFragment(x))==x round-trip. Guards null and objects not contained in the resource with descriptive exceptions.
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.



Implements
Resource.GetURIFragment(EObject), previously aNotImplementedExceptionstub, as the inverse ofGetEObject(string).Approach
ENamedElementis registered inResource.Cachekeyed by itsEObject.Identifier, andGetEObjectresolves a reference by that same key.GetURIFragmenttherefore returns the object'sIdentifier(the name-based Ecore reference, e.g.recipe.ecore#//Recipefor a class,EStructuralFeature::recipe.ecore#//Recipe/ingredientsfor a feature), which guarantees the round-tripGetEObject(GetURIFragment(x)) == xwith no change toGetEObject.null->ArgumentNullException; an object not contained in this resource -> a descriptiveInvalidOperationException(consistent with the guarded patterns from [Bug]: Guard unsafe casts onGetEObject(...)results #32/[Bug]: Validate attribute values before parsing #37).Design note / deviation from the ticket
The ticket listed a possible acceptance bullet that the fragment contain no leading
#. The existing architecture keys the cache by the composed identifier (which includes the<resource>.ecore#prefix), so returning that composed form is what round-trips with the currentGetEObject. Returning a pure intra-resource fragment (//Recipe) would require re-architectingGetEObject/BuildIdentifierand was deliberately left out of scope; the round-trip is satisfied as the primary contract. Happy to follow up with the pure-fragment form if desired.Tests (new
GetUriFragmentTestFixture): round-trip for the root package, a class, a structural feature and an enum literal, plusnulland not-contained guard cases. Full suite green (198 tests).Fixes #76.