Skip to main content



      Home
Home » Modeling » TMF (Xtext) » IJvmModelAssociations across models
IJvmModelAssociations across models [message #1758755] Sat, 01 April 2017 18:00 Go to next message
Eclipse UserFriend
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 12:05 Go to previous messageGo to next message
Eclipse UserFriend
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 14:05 Go to previous messageGo to next message
Eclipse UserFriend
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] Sun, 02 April 2017 22:46 Go to previous messageGo to next message
Eclipse UserFriend
Instill do. understand zero what you are doing in your code and what your problem is
Re: IJvmModelAssociations across models [message #1758788 is a reply to message #1758787] Mon, 03 April 2017 01:40 Go to previous messageGo to next message
Eclipse UserFriend
p.s. if you wantr to0 access components/injector of other dsls you can use IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uriOfAFileOfTheOtherDsl).get(XXXX.class);
Re: IJvmModelAssociations across models [message #1758818 is a reply to message #1758788] Mon, 03 April 2017 09:47 Go to previous message
Eclipse UserFriend
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: Wed Apr 23 16:49:46 EDT 2025

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

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

Back to the top