XText grammar for ecore model generated from XSD with choice elements [message #856351] |
Wed, 25 April 2012 15:31 |
Andreas Henriksson Messages: 6 Registered: April 2012 |
Junior Member |
|
|
Hi,
I'm currently doing some quick experiments with XText to write a concrete syntax for an existing XML schema based model that is used in-house. This schema uses the XSD <choice> element in a few places with a multiplicity > 1 to support mixing different elements in arbitary order.
An example of a XSD snippet is:
<element name="interfaceElement">
<annotation>
<documentation>
This is an interface element
</documentation>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="namespace1:elementA" />
<element ref="namespace1:elementB" />
</choice>
</complexType>
</element>
This will generate three properties in the ecore model for the InterfaceElementType since the choice element itself will spawn a EFeatureMap property that is named group by default.
For this element I would like to have a grammar description along the lines of this:
InterfaceType returns namespace1::InterfaceElementType:
'interface' '{'
((map+=MapType) | (port+=PortType))+
'}'
;
With this grammar the editor seems to work ok at first, but as soon as I start typing an interface element it will throw exceptions and error dialogs due to an illegal cast in the lazylinker during the validation. I've pasted the console output below at the end.
This leads me to believe that either XText is not handling this case at the moment or that I'm doing something very wrong here. If there is no "native" XText support out of the box, is there anyway to easily implement support for this in the form of a custom validator or something else? I would think so, but since the error is in the lazy linker part I became a bit unsure.
java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$ContainmentUpdatingFeatureMapEntry cannot be cast to org.eclipse.emf.ecore.EObject
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:117)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:104)
at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:491)
at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:127)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:62)
at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:79)
at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:75)
at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:64)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[Updated on: Wed, 25 April 2012 15:32] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.14159 seconds