Skip to main content



      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 14:48 Go to next message
Eclipse UserFriend
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 05:18 Go to previous messageGo to next message
Eclipse UserFriend
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 05:52 Go to previous messageGo to next message
Eclipse UserFriend
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 08:08 Go to previous messageGo to next message
Eclipse UserFriend
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 01:19 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: [XCore] how to create an EMF object instance in an operation? [message #1712648 is a reply to message #1712636] Tue, 27 October 2015 03:51 Go to previous messageGo to next message
Eclipse UserFriend
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 09:34 Go to previous messageGo to next message
Eclipse UserFriend
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 09:52 Go to previous message
Eclipse UserFriend
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 Nov 07 15:30:48 EST 2025

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

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

Back to the top