Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [Xtend] Cannot create instance of abstract class
[Xtend] Cannot create instance of abstract class [message #650514] Tue, 25 January 2011 11:35 Go to next message
Ivir is currently offline 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 abstract class [message #659580 is a reply to message #650514] Mon, 14 March 2011 16:31 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf Bigalk
Messages: 41
Registered: July 2009
Location: Berlin
Member
Hi Ivir,

I have the same problem. Did you find out anything yet?
Re: [Xtend] Cannot create instance of abstract class [message #662328 is a reply to message #650514] Wed, 30 March 2011 09:23 Go to previous messageGo to next message
MaximeLecourt  is currently offline MaximeLecourt
Messages: 108
Registered: February 2010
Location: France
Senior Member
An Abstract class is by definition abstract and can't be instanced, so I'm not sure what you are asking.

One day I shall master M2T, but that day has yet to come...
Re: [Xtend] Cannot create instance of model class [message #662622 is a reply to message #662328] Thu, 31 March 2011 10:32 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf Bigalk
Messages: 41
Registered: July 2009
Location: Berlin
Member
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 abstract class [message #662632 is a reply to message #650514] Thu, 31 March 2011 11:17 Go to previous messageGo to next message
MaximeLecourt  is currently offline MaximeLecourt
Messages: 108
Registered: February 2010
Location: France
Senior Member
I never used XText, always Xtend directly, so I can't say.

You should ask your question on M2T forum, there should be more people able to help there.


One day I shall master M2T, but that day has yet to come...
Re: [Xtend] Cannot create instance of model class [message #662780 is a reply to message #662622] Thu, 31 March 2011 21:59 Go to previous messageGo to next message
Didier Villevalois is currently offline Didier Villevalois
Messages: 86
Registered: July 2009
Member
Hello Olaf,

On Thu, 2011-03-31 at 06:32 -0400, Olaf Bigalk wrote:
> 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?

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.
icon7.gif  Re: [Xtend] Cannot create instance of model class [message #662916 is a reply to message #662780] Fri, 01 April 2011 13:22 Go to previous message
Olaf Bigalk is currently offline Olaf Bigalk
Messages: 41
Registered: July 2009
Location: Berlin
Member
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

Previous Topic:[QVTo] How to find specific object in a list
Next Topic:[ATL] String.split() method does not run
Goto Forum:
  


Current Time: Wed Sep 17 23:52:27 GMT 2014

Powered by FUDForum. Page generated in 0.02263 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software