[Feature] implement EObject.EClass() (return the meta class); fixes #10#78
Merged
Conversation
…fixes #10 Resolve the Ecore meta class for an EObject by looking up // + runtime type name in the resource's registered eCoreTypes (new internal Resource.GetMetaClass helper), matching the EMF eClass() contract. Guards unregistered types with a descriptive exception.
Add tests for the no-registered-meta-class throw path of EObject.EClass() and the unknown-type-name null return of Resource.GetMetaClass(string), bringing new-code coverage on #10 to 100% (>= 80% quality gate). Also document the 80% new-code coverage requirement in CLAUDE.md.
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
EObject.EClass(), previously aNotImplementedExceptionstub, per the EMFeClass()contract: it returns the meta class describing the element's own type (e.g. anEAttributeinstance returns theEClassnamedEAttribute).Approach
Resource.GetMetaClass(string)helper that looks up the meta class already registered ineCoreTypesunder//<TypeName>and returns it typed asEClass.EObject.EClass()resolves viaEResource.GetMetaClass(this.GetType().Name)(the CLR type names match the registered meta-class names), guarding an unregistered type with a descriptiveInvalidOperationException. The meta class returned belongs to the same resource as the object. Purely additive - no change toGetEObject/registry keys.Tests
New
EObjectMetaClassTestFixture: meta-class name forEPackage/EClass/EAttribute/EReference/EEnum/EEnumLiteral; that the returned meta class is the resource-registeredEClassinstance; and consistency across instances of the same type. Full suite green (201 tests).Note on the ticket
Issue #10's stated use-case (checking whether the
EClassreferenced by aStructuralFeatureas itsETypeis abstract) is unrelated toeClass()per the Ecore spec -eClass()returns the metaclass, not theEType. That use-case is already supported viafeature.EType as EClass+.Abstract. This PR implements the correcteClass()semantics; the issue text was left unchanged.Fixes #10.