[Xtend] Cannot create instance of abstract class [message #650514] |
Tue, 25 January 2011 11:35 |
Ivir Messages: 2 Registered: April 2010 |
Junior Member |
|
|
I am trying to migrate my M2M xtend project, but i am stuck at the point when i get this error:
xtend file:
create Model2 this transform(Model1 m) :
...
mwe2 output:
org.eclipse.emf.mwe.core.WorkflowInterruptedException: Cannot create instance of abstract class Model2
...
Can anyone help?
[Updated on: Tue, 25 January 2011 11:36] Report message to a moderator
|
|
|
|
|
Re: [Xtend] Cannot create instance of model class [message #662622 is a reply to message #662328] |
Thu, 31 March 2011 10:32 |
|
Hallo Maxime,
I have defined a model with Xtext. And I want to instantiate one class of this model. The Xtext generator generates Interface classes and implementation classes for the model but it is neither possible to instantiate the interface what is obvious nor it is possible to instantiate the implementation class because it is not visible to the Xtend language.
The question is, how can I instantiate a class from my model?
|
|
|
|
|
Re: [Xtend] Cannot create instance of model class [message #662916 is a reply to message #662780] |
Fri, 01 April 2011 13:22 |
|
Didier Villevalois wrote on Thu, 31 March 2011 17:59 | Hello Olaf,
I never used Xtend. However it seems to me that the model generation you
speak about is standard EMF Ecore codegen generated code.
So it should also have generated a MyModelPackage and MyModelFactory
classes. Thoses classes will give you all of what you need.
To instanciate a ModelClassX model object do:
MyModelFactory.eInstance.createModelClassX()
Didier.
|
Hallo Didier,
thank you for this tip. The solution I found is this:
create MetaModelFactory makeMetaModelFactory() :
this
;
ExpandParameter makeExpandParameter(Type this, String category, String name, String value) :
let param = makeMetaModelFactory().createExpandParameter() :
param.setType(this)->
param.setCategory(category)->
param.setVarName(name)->
param.setValue(value)->
param
;
[Updated on: Fri, 01 April 2011 13:23] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01906 seconds