Skip to content

Support EAnnotation.contents via a dynamic EObject implementation #109

Description

@samatstariongroup

Context

Split out of #106 (itself a follow-up to #99/#105) because it is materially larger than the other
reading-compatibility items and is really its own feature: supporting the EAnnotation.contents
containment feature requires a dynamic EObject implementation that ECoreNetto does not currently
have.

Problem

EAnnotation has a containment feature contents that holds arbitrary EObjects — for example an
OCL/Pivot AST, or any model element whose type is declared elsewhere. A serialized annotation looks
like:

<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
  <contents xsi:type="pivot:ExpressionInOCL"> ... </contents>
</eAnnotations>

#99/#105 added EAnnotation.references (a non-containment reference list) but not contents.
ECoreNetto has no dynamic EObject instance: every model class in ModelElement/ is a fixed
metamodel type (EClass, EAttribute, …). A <contents xsi:type="somepkg:SomeClass"> element would
need a general "create an instance of an arbitrary EClass" path that the fixed classes do not
provide, so contents is currently dropped on read.

Direction

  • Introduce a dynamic EObject (an EObjectImpl-style instance backed by its EClass, holding its
    feature values reflectively) — the analogue of EMF's DynamicEObjectImpl.
  • Add a generic factory keyed by xsi:type that resolves the EClass (via the type's EPackage
    nsURI + local name) and instantiates the dynamic object.
  • Deserialize EAnnotation.contents with that factory, recursively reading child elements and
    attributes into the dynamic instance's feature values.

Notes / references

  • Reference implementation: org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/DynamicEObjectImpl.java,
    EcoreUtil.create(EClass), and the generic EFactoryImpl.create. EObjectImpl.eGet/eSet show the
    reflective feature-value storage.
  • Independent of the other EMF reading-compatibility follow-ups: @feature.N positional fragments, xmi:id resolution #106 items (@feature.N positional fragments and bare xmi:id
    resolution), which do not need dynamic objects.
  • Rare in hand-authored .ecore, but appears in tool-generated metamodels that embed OCL/Pivot
    annotations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions