Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » IJvmModelAssociations across models
IJvmModelAssociations across models [message #1758755] Sat, 01 April 2017 22:00 Go to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
I have two linked grammars that complement each other.
I can use the normal scoping context to link to a model from the other grammar just fine.
Example Model DSL:
Model
     prop1  : Integer
     prop2 :  Model2
  
Model2
   prop1 
   prop2


When referring to a Model from my second DSL, I can find the properties just fine. However, when it refers to a property of model2, I need to match it to the right EObject to go fetch the properties.

In the Model DSL, I use
IJvmModelAssociations.getSourceElements(theJVMTypeForModel2)


In the context of the Model DSL, this works properly. But it seems to me like the IJvmModelAssociations is bound to the associations for a specific DSL...

Any way I can do it clean without doing some weird global variable somewhere ?

Last point. It's normal that I have to go through the JVM type at that point, because that type of reference is permitted, it will just (rightly so) not return any properties.


Thanks

Re: IJvmModelAssociations across models [message #1758774 is a reply to message #1758755] Sun, 02 April 2017 16:05 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
OK, The problem was not related to the injected IJvmModelAssociations.
I was using the wrong type reference cast in that specific instance.

I would have deleted the post, but it's not available as an option.

Thanks
Re: IJvmModelAssociations across models [message #1758777 is a reply to message #1758774] Sun, 02 April 2017 18:05 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
Update on the issue. My fix worked only if I managed to get a reference to the IJvmModelAssociations injected in the ModelDsl scopes provider... So I'm back to square one.
My program works because of the way I've statically referenced it, but it doesn't look like it's the right way to do it.
So your suggestions are still welcome

Re: IJvmModelAssociations across models [message #1758787 is a reply to message #1758777] Mon, 03 April 2017 02:46 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Instill do. understand zero what you are doing in your code and what your problem is

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: IJvmModelAssociations across models [message #1758788 is a reply to message #1758787] Mon, 03 April 2017 05:40 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
p.s. if you wantr to0 access components/injector of other dsls you can use IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uriOfAFileOfTheOtherDsl).get(XXXX.class);

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: IJvmModelAssociations across models [message #1758818 is a reply to message #1758788] Mon, 03 April 2017 13:47 Go to previous message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
I wanted to use the JvmModelAssociations of one model in the scoping engine of another one. With your suggestion I was able to make it clean with
@Inject IResourceServiceProvider.Registry registry

and use it with:
val associations = registry.getResourceServiceProvider(type.eResource.URI).get(IJvmModelAssociations)

It works. Thanks for the new tip.
Previous Topic:Scope for custom XVariableDeclaration
Next Topic:Optimizing build performance - observing redundant calls to isAffected and validation
Goto Forum:
  


Current Time: Sat Sep 18 08:30:01 GMT 2021

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

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

Back to the top