Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » How to use an external class as a black-box library?
How to use an external class as a black-box library? [message #1785399] Fri, 13 April 2018 13:24 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

I need to use some methods from a class defined in some Eclipse plugin. I registered this class:
<plugin>
   <extension
         point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">
      <library
            class="org.eclipse.emf.ecore.xcore.mappings.XcoreMapper"
            name="XcoreMapper">
      </library>
   </extension>
</plugin>

But the following imports still doesn't work:
import XcoreMapper;
import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;

How to fix it?


I think my second question is unrelated to QVTo. But in any case, maybe someone will help me. I need to transform an Xcore model into some Ecore model. During transformation I need to get super classes of some Xcore class:
some_xclass.superTypes

This code returns a set of XGenericType instances. But I need to get a set of XClass instances.

I can get a set of EClass instances using the following expression:
some_xclass.superTypes.type[GenClass].ecoreClass[EClass]

But It seems that the only possible way to map EClass instances back to XClass instances is to use the following method: org.eclipse.emf.ecore.xcore.mappings.XcoreMapper::getXClass()

So to get a set of super classes I have use a black-box library and to write something like:
some_xclass.superTypes.type[GenClass].ecoreClass[EClass]->collect(getXClass())

That's terrible! Maybe you can suggest a simpler approach?
Re: How to use an external class as a black-box library? [message #1785409 is a reply to message #1785399] Fri, 13 April 2018 14:01 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
It seems I don't need a black-box library. Any Xcore model contains an Ecore model. So in my QVTo transformation I can get an EPackage instead of XPackage and transform it as usual. The problem is that it seems that Xcore is broken: https://www.eclipse.org/forums/index.php/t/1092229/
Re: How to use an external class as a black-box library? [message #1785413 is a reply to message #1785409] Fri, 13 April 2018 14:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm not familiar with XClass, but it seems that you have the regular problem with layered architectures; the derived types keep getting lost and you have to write ugly code to keep recovering them. Same problem in Java. Best to try to never lose the Xcore types. Navigating via GenModel seems like a way to make things super-complicated. If XGenericType is anything like EGenericType you just do getEClassifier().

Blackboxes are a necessary evil to workaround the limitations of immutable bad metamodels or for performance or for major re-use. Try to avoid wherever possible.

"But the following imports still doesn't work:". Did your machine catch fire then?

Regards

Ed Willink
Re: How to use an external class as a black-box library? [message #1785468 is a reply to message #1785413] Sat, 14 April 2018 14:38 Go to previous message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

Thanks for answer! It seems that it's better not to use XPackage, XClass, etc. at all. As I see now each Xcore resource contains a regular Ecore model as well.
Previous Topic:generating .qvtotrace file fails
Next Topic:Using QVTo with Xtext
Goto Forum:
  


Current Time: Thu Apr 25 17:14:07 GMT 2024

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

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

Back to the top