Open krissrex opened 3 years ago
What is the instanceClassName of ActionId? I assume it is java.lang.String. I think this JSON stringify stuff has to be removed entirely as it is not compatible with the Java implementation of XmiResource. I need to look it up, but I can barely remember that in Java EDataTypes have to implement the Serializable interface. Maybe there is a way to port this to TypeScript.
What the original Java implementation has this fallback: https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EFactoryImpl.java#n290. For now, I cannot see that it makes sense to port this logic to TypeScript. On the other side, the Javadoc says that clients have to hand-write createXyzFromString and createXyzToString http://download.eclipse.org/modeling/emf/emf/javadoc/2.7.0/org/eclipse/emf/ecore/EDataType.html#isSerializable(). In the long term this is my plan how to proceed:
In the meanwhile, I suppose that you override createXyzFromString by hand and are aware that every time you run the CrossEcore generator, your manual changes in *FactoryImpl are overriden (as long as @generated NOT is not supported)
Some createXyzFromString and createXyzToString for the built-in EDataTypes of Ecore are implemented in 0.2.0 https://github.com/crossecore/ecore-typescript/pull/28
Description: I am trying to deserialize xmi. One of the
EDataTypes
I created (ActionId
) has a value"ecore:new_child"
. When the code tries to create thisActionId
, it runs this:This assumes the
initialValue
(which isecore:new_child
) is valid json, and it crashes:It gets there via
XmiResource.addEStructuralFeatures
(line 169):var literalvalue = _this.factory.createFromString(etype, value);
then via my Factory'spublic createFromString(eDataType:EDataType, initialValue:string)
to the snipped shown first.It would work if my initialvalue was wrapped in quotes:
"ecore:new_child"
. But thisEDataType
was not stringified by the crossecore library, but the Eclipse IDE editor for xmi.This is an excerpt of the xmi: