Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCore] how to create an EMF object instance in an operation?
[XCore] how to create an EMF object instance in an operation? [message #1712476] Sun, 25 October 2015 18:48 Go to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
How do I create an instance of another EMF object in an operation? I tried:

op MyObject build()
{
val MyObject = MyFactory.eINSTANCE.createMyObject()
}

and that doesn't work.
Re: [XCore] how to create an EMF object instance in an operation? [message #1712516 is a reply to message #1712476] Mon, 26 October 2015 09:18 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Saying something "doesn't work" isn't very helpful. Doesn't it compile
or generate code? Does the generated code crash? What error messages
are provided? Also, knowing what version(s) you are using and what
libraries are on the class path is also useful.

Hallvard

On 2015-10-25 18:48:47 +0000, Bryan Hunt said:

> How do I create an instance of another EMF object in an operation? I tried:
>
> op MyObject build()
> {
> val MyObject = MyFactory.eINSTANCE.createMyObject()
> }
>
> and that doesn't work.


--
Hallvard Trætteberg (hal@xxxxxxxx.no)
Associate Professor, IS group, Dept. of Computer and Information
Science at the
Norwegian Univ. of Science and Technology
Re: [XCore] how to create an EMF object instance in an operation? [message #1712522 is a reply to message #1712516] Mon, 26 October 2015 09:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The debugger is always your friend when you have no better ideas.

One possible avenue to investigate is the use of a return statement.

Regards

Ed Willink


On 26/10/2015 09:18, Hallvard Trætteberg wrote:
> Saying something "doesn't work" isn't very helpful. Doesn't it compile
> or generate code? Does the generated code crash? What error messages
> are provided? Also, knowing what version(s) you are using and what
> libraries are on the class path is also useful.
>
> Hallvard
>
> On 2015-10-25 18:48:47 +0000, Bryan Hunt said:
>
>> How do I create an instance of another EMF object in an operation? I
>> tried:
>>
>> op MyObject build()
>> {
>> val MyObject = MyFactory.eINSTANCE.createMyObject()
>> }
>>
>> and that doesn't work.
>
>
Re: [XCore] how to create an EMF object instance in an operation? [message #1712560 is a reply to message #1712516] Mon, 26 October 2015 12:08 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
I'm using the latest release version. The editor gives the following error:

Couldn't resolve reference to JvmIdentifiableElement 'eINSTANCE'.

There is a quick fix to "Change to INSTANCE" if you click that, the editor is happy, but the generated code does not compile. The error message is:

INSTANCE could not be resolved or is not a field.
Re: [XCore] how to create an EMF object instance in an operation? [message #1712636 is a reply to message #1712560] Tue, 27 October 2015 05:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Bryan,

That works for me. Are there @GenModel annotations involved?


On 26/10/2015 1:08 PM, Bryan Hunt wrote:
> I'm using the latest release version. The editor gives the following
> error:
>
> Couldn't resolve reference to JvmIdentifiableElement 'eINSTANCE'.
>
> There is a quick fix to "Change to INSTANCE" if you click that, the
> editor is happy, but the generated code does not compile. The error
> message is:
>
> INSTANCE could not be resolved or is not a field.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [XCore] how to create an EMF object instance in an operation? [message #1712648 is a reply to message #1712636] Tue, 27 October 2015 07:51 Go to previous messageGo to next message
Mikaël Barbero is currently offline Mikaël BarberoFriend
Messages: 3
Registered: February 2015
Junior Member
Bryan,

In addition to Ed's question, did you set the genmodel option suppressInterfaces to "true"? I can reproduce your error with this option set to true.
Re: [XCore] how to create an EMF object instance in an operation? [message #1712686 is a reply to message #1712648] Tue, 27 October 2015 13:34 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Yes, suppress interfaces is true

@GenModel(suppressInterfaces="true", copyrightText="Copyright (c) 2015 Bryan Hunt\n\nAll rights reserved. This program and the accompanying materials\nare made available under the terms of the Eclipse Public License v1.0\nwhich accompanies this distribution, and is available at\nhttp://www.eclipse.org/legal/epl-v10.html\n\nContributors:\n Bryan Hunt - initial API and implementation\n")
@GenModel(runtimePlatform="RCP")
Re: [XCore] how to create an EMF object instance in an operation? [message #1712694 is a reply to message #1712686] Tue, 27 October 2015 13:52 Go to previous message
Mikaël Barbero is currently offline Mikaël BarberoFriend
Messages: 3
Registered: February 2015
Junior Member
I think you can fill a bug about this.
Previous Topic:[XCore] how to specify constants?
Next Topic:[CDO] CDO_CLASS column in CDO_OBJECTS table
Goto Forum:
  


Current Time: Fri Apr 26 17:04:44 GMT 2024

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

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

Back to the top