Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] Using rootExtendsInterface
[xcore] Using rootExtendsInterface [message #1821193] Thu, 06 February 2020 20:18 Go to next message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

i have an .xcore model that uses the 'rootExtendsInterface' and 'rootExtendsClass' fields from in the @GenModel annotation.
But when this root interface should be used in as type of an attribute in a class, it must be wrapped first. This leads to strange behavior in some cases, because The root class and the wrapped class are not of the same type.

Example:

package test.base;
import org.eclipse.emf.ecore.EObject;
public interface MyRoot extends EObject {}

package test.base;
import org.eclipse.emf.ecore.impl.EObjectImpl;
public class MyRootImpl extends EObjectImpl implements MyRoot  {}

@GenModel(rootExtendsInterface="test.base.MyRoot", rootExtendsClass="test.base.MyRootImpl")
package test.model

import test.base.MyRoot

class MyRoot wraps MyRoot {}

class TestClass 
{
    contains MyRoot root
}


EObject for example can be used without wrapping. What do i have to do to make the root class usable in the model without wrapping?

Regards
Matthias
Re: [xcore] Using rootExtendsInterface [message #1821199 is a reply to message #1821193] Fri, 07 February 2020 04:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31841
Registered: July 2009
Senior Member
You cannot make a non-modeled interface usable without wrapping it. But you can wrap it using "interface MyRoot wraps MyRoot {}" such that no MyRootImpl is generated in the test.model.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] Using rootExtendsInterface [message #1821981 is a reply to message #1821199] Tue, 25 February 2020 05:14 Go to previous messageGo to next message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

Sorry for the delayed response, but i was not able to investigate this problem further until now.
The solution seems to work.
But now there is another problem:
The RootClass and/or RootInterface are not listed as super types of the classes in the model. Is there any way I can fix that?

Regards
Matthias
Re: [xcore] Using rootExtendsInterface [message #1821983 is a reply to message #1821981] Tue, 25 February 2020 06:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31841
Registered: July 2009
Senior Member
This is contrary to the use of rootExtendsInterface/rootExtendsClass. The point of using these is to hide that information from the modeled EClasses. This information is used only when generating interfaces/classes to extend some arbitrary interface/class in a way that is not reflectively visible in the model. By default all generated root interfaces extend EObject and generated root classes extend org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container, but if you ask that EClass for its super types, EObject will not be present. This is the goal and the purpose. If, contrary to that goal, you want information to be reflectively available, you must model it explicitly that way.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] Using rootExtendsInterface [message #1821984 is a reply to message #1821983] Tue, 25 February 2020 07:43 Go to previous message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

ok, I was not aware of this. I will try to change my model in that way and do not use the rootExtendsInterface/rootExtendsClass. Seems that I was missusing this feature as a shortcut to add base classes to all classes of my model without the effort to model.

Thank You,
Matthias
Previous Topic:[CDO] Possibly deadlock during the session invalidation
Next Topic:Forum on Privacy and Data Protection Challenges in System Development
Goto Forum:
  


Current Time: Tue Apr 20 14:56:29 GMT 2021

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

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

Back to the top