Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] EcorePackage version issue (in Xtext validator)
[Xcore] EcorePackage version issue (in Xtext validator) [message #1751039] Tue, 03 January 2017 20:20 Go to next message
Joel Greenyer is currently offline Joel GreenyerFriend
Messages: 20
Registered: October 2014
Junior Member
Hi all,
I have an Xtext-based language where in the language I can I reference elements from an Ecore or Xcore model.

When referencing elements from an Xcore model, there seems to be an issue with different version of the EcorePackage. For example, in a validator function, when I say

if (operand.expressionType == EcorePackage.Literals.EBOOLEAN) ...

the check returns an erroneous result because
expression.expressionType.EPackage
is not the same as
EcorePackage.eINSTANCE
(using Xtend syntax here)

They are both ecore packages, but one is an instance of ECorePackageImpl, while the other is an instance of EPackageImpl.

The problem does not occur when I reference elements from a plain Ecore model.

Any ideas of how to solve this issue?

Thanks

Joel
Re: [Xcore] EcorePackage version issue (in Xtext validator) [message #1751056 is a reply to message #1751039] Wed, 04 January 2017 06:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
It's best not to assume that EcorePackage.eINSTANCE will necessarily be the only one used. The serialized Ecore.ecore can be loaded as a resource into any resource set. Even the Sample Ecore Editor the Load Resource... gives you a choice, i.e., Browse Target Platform Packages... will load the serialized Ecore.ecore into a resource. Xcore tries to consistently use EPackages from the target platform in all cases; I say tries, because an Ecore model may reference either one which is why GenPackageImpl has a method like this:
  public boolean isEcorePackage()
  {
    return (EcorePackage.eNS_URI.equals(getNSURI()));
  }
I don't know the full context of your application, perhaps you should be testing that operand.expressionType.instanceClass is the class for "boolean" or that operand.expressionType.instanceClassName is the value "boolean". After all, XMLTypePackage.Literals.BOOLEAN is also an EDataType that wraps "boolean" and of course any model could provide a different wrapper (and even serialize the instance value differently).


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Customize refresh of the editor based on EMF.Edit
Next Topic:XML Binding to EMF
Goto Forum:
  


Current Time: Fri Apr 26 22:38:45 GMT 2024

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

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

Back to the top