Creating Proxies from JvmType [message #982159] |
Tue, 13 November 2012 00:40 |
Jens-Uwe Moeller Messages: 12 Registered: March 2012 Location: Hamburg |
Junior Member |
|
|
Hi,
I tried out Michael Vorburgers approach to XML-Generation of the parsed Code in my DSL and it works fine, as long as my self-defined classes are concerned.
As far, as I understood his approach, he makes a kind of copy of the resource with all its element and copies all references, and then modifies it to meet XML needs (uri name:/ etc.)
Ok, it worked fine for the Fowler-Dsl StateMachine, but when having a parser rule that uses JvmTypeReference or something else from JvmType like the Enitity-Rule
Entity:
name=ValidID ('extends' superType=JvmParameterizedTypeReference)?
or
Property:
name=ValidID ':' type=JvmTypeReference;
it gets as error: The class 'JvmType' is not a valid classifier
coming from the TypesFactory "org.eclipse.xtext.common.types.impl.TypesFactoryImpl".
There
public EObject create(EClass eClass)
{
switch (eClass.getClassifierID())
the call of eClass.getClassifierID() always results in 0.
First I thought, that the error might result from a non-initialized resource or an anyway other incomplete state, so I subclassed JvmModelAssociator, and later the JvmModelGenerator. But even in the latter case the error stayed. So there must be another reason. I expected there a "JvmParameterizedTypeReference" instead of a "JvmType" - but maybe my expectation is wrong.
Either it is wrong, to try to create a proxy by calling EcoreUtil.create with
eReference.getEReferenceType()
where eReference is inititialised by the following code from Michael
protected <T extends EObject> void replaceReferences(T rootObject, ReferenceReplacer r) {
Map<EObject, Collection<Setting>> map = EcoreUtil.CrossReferencer.find(Collections.singleton(rootObject));
for (Map.Entry<EObject, Collection<EStructuralFeature.Setting>> entry : map.entrySet()) {
EObject crossReference = entry.getKey();
for (Setting setting : entry.getValue()) {
EReference eReference = (EReference)setting.getEStructuralFeature();
or the TypesFactory has to be broadend.
Can you help me to understand, how proxies of elements of Jvm... could be build and which are the relevant objects that proxies have to be build from.
Thanks in advance, Jens
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03384 seconds