Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xbase: Add own EMF-classes to the model
Xbase: Add own EMF-classes to the model [message #1632594] Tue, 24 February 2015 11:12 Go to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 111
Registered: July 2009
Senior Member
Hello,

in order to reduce complexity of my Xbase-JvmModelInferrer I decided to extend EMF-model with some new attributes and classes:


  • First I switched to Xcore using Jan's blog: http://koehnlein.blogspot.de/2013/06/using-xcore-in-xtext.html
  • Then I started to add new attributes and classes
  • In the JvmModelInferrer I first iterate through my model and set all the new attributes and create instances of the new classes.
  • Inferring JvmModel later on I can use not only standard EMF-Model , but also all my new calculated attributes and classes, that makes inferring a lot easier. It also works as a cache.


But unfortunately this doesn't work smooth yet. There are my problems:


  • I had to make all my new attributes transient in order to avoid exceptions, saying that those new attributes (references) are not mapped to the grammar and though can't be serialized.
  • In the consequent runs of the JvmModelInferrer my new references get replaced with proxies making my model useless.


Here is an example of my Xcore:

// Xtext stuff. Mapped to grammar
class Parameter  {
    ...
    // Add containment reference to my new EClass
    contains transient ParameterModel paramerModel opposite parameter
}

// My new class, not mapped to the grammar
class ParameterModel {
    // Reference to the container
    container transient Parameter parameter opposite parameterModel

    // My calculated type reference (cloned with proxies)
    contains transient JvmTypeReference rowType // !!! Get replaced by proxy at some point !!!
}



My question is, how to add new classes properly and is it a right way to go in the first place?
Is there some example of complex model inferring with caching?

Thank you!


Cheers,
Boris


Re: Xbase: Add own EMF-classes to the model [message #1632602 is a reply to message #1632594] Tue, 24 February 2015 11:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
Did you have a look at the transientvalueservice as well? it is used to determine transient attributes programmatically

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase: Add own EMF-classes to the model [message #1632661 is a reply to message #1632594] Tue, 24 February 2015 12:04 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1775
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I'm doing something similar in Xsemantics,
https://github.com/LorenzoBettini/xsemantics

but I define the transient attributes as unsettable, so that I can set
them on demand, by checking whether such attributes are set or not. For
example, I have extension methods for reading such attributes and if
they are not set I compute their values and set them.

I haven't experienced any particular problem with such approach

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Xbase: Add own EMF-classes to the model [message #1645643 is a reply to message #1632661] Mon, 02 March 2015 16:11 Go to previous message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 111
Registered: July 2009
Senior Member
Hello,


thank you for tips!

Unfortunately I didn't managed to get it to work yet. If I do, I will post the answer.


Cheers,
Boris
Previous Topic:Flaky "Ambiguous feature call" error with Xtend 2.7.3
Next Topic:import of namespace in Xtext editor
Goto Forum:
  


Current Time: Sat Apr 17 00:41:15 GMT 2021

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

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

Back to the top