EnumLiteralDeclaration: problem getting the values of the reference [message #1153240] |
Thu, 24 October 2013 13:21 |
d 627 Messages: 28 Registered: March 2013 |
Junior Member |
|
|
Hi there
I am kind of new in xtext, but I have been working in my project with some problems. One of this concerns the values of the references on EnumLiteralDeclaration. In theory there are two features supported: enumliteral and literal.
In my procedure when arrive an object of the EnumLiteralDeclaration kind, I am printing the two features inside the object just to try to understand what is happening.
As output I am having this:
quantity of references: 2
The references are: [org.eclipse.emf.ecore.impl.EReferenceImpl@93a061 (name: enumLiteral) (ordered: true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (containment: false, resolveProxies: true),
org.eclipse.emf.ecore.impl.EReferenceImpl@d7e37c (name: literal) (ordered: true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (containment: true, resolveProxies: false)]
- The value of literal is null.
The object is null
As you can see I am having the value of just one reference (literal) and not the value of enumLiteral even when I can see it with some values in its attributes. Instead of that I having a null object.
(Once again I am kind of new in xtext so I am also ignorant in some aspects, I hope you can understand that and can give a respectful answer).
Thanks a lot.
Regards.
[Updated on: Thu, 24 October 2013 14:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: EnumLiteralDeclaration: problem getting the values of the reference [message #1153581 is a reply to message #1153552] |
Thu, 24 October 2013 18:09 |
|
hmmmm somehow there is no tar anymore.
never the less back to xtexts grammar itself:
EnumLiteralDeclaration:
enumLiteral=[ecore::EEnumLiteral] ('=' literal=Keyword)?
;
this practically means in a grammar you could write
enum MyEnum :
aEnumLiteral | anotherEnumLiteral="AndItsLiteral"
;
and here is the part of Xtexts Metamodel
<eClassifiers xsi:type="ecore:EClass" name="EnumLiteralDeclaration" eSuperTypes="#//AbstractElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="enumLiteral" eType="ecore:EClass platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore#//EEnumLiteral"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="literal" eType="#//Keyword"
containment="true"/>
</eClassifiers>
from the code you posted (no zip) i cannot see where you actually call
eobject.eGet(feature)
btw maybe the class XtextSwitch is a better way to traverse the grammar
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: EnumLiteralDeclaration: problem getting the values of the reference [message #1153613 is a reply to message #1153581] |
Thu, 24 October 2013 18:36 |
|
HI,
the file was still there in the newsgroup.
the problem is that the loaded resource had errors.
the following works for me
StandaloneSetup standaloneSetup = new StandaloneSetup();
standaloneSetup.setPlatformUri("../");
standaloneSetup.addRegisterEcoreFile("platform:/resource/lala/src/VCML.ecore");
Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
URI uri1 = URI.createURI("platform:/resource/lala/src/a.xtext");
Resource resourceVers1 = resourceSet.getResource(uri1, true);
EcoreUtil.resolveAll(resourceSet);
System.out.println(resourceVers1.getErrors());
EObject root = resourceVers1.getContents().get(0);
navigateEObject(root);
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05207 seconds