Skip to main content



      Home
Home » Modeling » EMF » [xcore] Using rootExtendsInterface
[xcore] Using rootExtendsInterface [message #1821193] Thu, 06 February 2020 15:18 Go to next message
Eclipse UserFriend
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] Thu, 06 February 2020 23:58 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: [xcore] Using rootExtendsInterface [message #1821981 is a reply to message #1821199] Tue, 25 February 2020 00:14 Go to previous messageGo to next message
Eclipse UserFriend
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 01:24 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: [xcore] Using rootExtendsInterface [message #1821984 is a reply to message #1821983] Tue, 25 February 2020 02:43 Go to previous message
Eclipse UserFriend
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: Sat Nov 08 03:01:43 EST 2025

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

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

Back to the top