Grammer for UML-Association [message #1143897] |
Fri, 18 October 2013 09:55  |
Eclipse User |
|
|
|
Hello everyone!
I'm trying to write a grammer for UML-Classdiagrams by importing the UML2 metamodel and writing the necessary xtext-grammer.
Everything runs well (for example the parsing rules for: Classes, Enums, Properties, Datatypes, Inheritage etc..) except associations. Here is a snippet of my Grammer which describes this:
Association_Impl returns Association:
{Association}
(isAbstract?='isAbstract')?
'assoc' name=ID ('specializes' generalization+=Generalization_Impl)?
'{'
//The properties of an association are the association ends whose values are
// the instances being related by a specific instance of the association.
//Two properties (asso ends) are prescribed, one is optional
(ownedEnd+=Property_Association_Impl)*
//member-end min 2x
'role_1:' memberEnd+=[Property|QualifiedName] ';'
'role_2:' memberEnd+=[Property|QualifiedName] ';'
('further_roles: '(memberEnd+=[Property|QualifiedName] ';')* )?
'}'
;
I think the problem is this feature of an association:
(ownedEnd+=Property_Association_Impl)* .
It is not possible to create these properties (they are not visible in the outline-view). The uml-metamodel expects that all necessary references of these properties are already set!
My question is now: Is it possible to instantiate some model-elements programmatically by default??
I thought about something like:
- user writes an association
- xtext creates an association-instance with two ownedEnd-Properties
Maybe someone has an idea?
Thanks alot,
Alex
|
|
|
|
|
|
|
Re: Grammer for UML-Association [message #1161174 is a reply to message #1161051] |
Tue, 29 October 2013 12:30  |
Eclipse User |
|
|
|
Hello,
I fixed now the incomming exceptions by adding the necessary features to my DSL-rules. So the programmatically creation of these properties runs and the textual syntax is also generated
in the xtexteditor. But now I get the following exception from xtext:
1 [Worker-3] ERROR org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy - Parsing in reconciler failed.
org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=1, size=0
at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:478)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:559)
at org.eclipse.emf.common.util.AbstractTreeIterator.next(AbstractTreeIterator.java:133)
at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.clearAllReferences(AbstractCleaningLinker.java:75)
at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.beforeModelLinked(AbstractCleaningLinker.java:65)
at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:37)
at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:282)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:88)
at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:250)
at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:240)
at org.eclipse.xtext.resource.XtextResource.update(XtextResource.java:221)
at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.doReconcile(XtextDocumentReconcileStrategy.java:125)
at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.reconcile(XtextDocumentReconcileStrategy.java:55)
at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.doRun(XtextReconciler.java:329)
at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.access$3(XtextReconciler.java:316)
at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:273)
at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:1)
at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.modify(AbstractReadWriteAcces.java:81)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:201)
at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:98)
at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:270)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Does someone has any idea what is the problem here?
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.24102 seconds