How to share model instanced between Xtext generated model and referred DomainModel [message #689024] |
Sun, 26 June 2011 15:00 |
|
Hi,
This was my use case, I was writing a grammar for simple business rules:
"age > 18"
The rule for each comparison expression looks like this:
ComparisonExpression:
(variable=[Variable]) '>' INT
where 'age', 'gender' and 'DOB' are instances of [Variable] that come from a referenced Ecore model (MyDomainModel) in my workspace.
With a lot of help in my previous posts I was able to generate the ecore model "BusinessRulesModel", content assists etc from my grammar.
My next question is following:
In my runtime work bench MyDomainModel instances are created and hence instances of EClass "Variable" such as "age", "gender" and "DOB" are also created. I want to use these instances in my Xtext generated BusinessRuleModel.
How do I integrate the two. Thanks for any help.
Best Regards,
Nidhi
|
|
|
|
|
|
Re: How to share model instanced between Xtext generated model and referred DomainModel [message #689080 is a reply to message #689076] |
Sun, 26 June 2011 18:46 |
|
Hi Christian,
I have created my own ResourceServiceProvider, ResourceDescription and ResourceDescriptionManager.
Have also overridden the computeExportedObjects() to identify the objects that need to be exported.
But am lost at this point. In the org.eclipse.xtext.core, I see 3 other classes implementing IWorkflowComponent, extends AbstractGenericModule and implements IEncodingProvider. I dont understand Google Guice as well.
Do I need these too or just identifying the the exported Objects is sufficient. Can you please help me understand this better. Is there any short tutorial you can point me to.
Best Regards,
Nidhi
|
|
|
|
|
|
Re: How to share model instanced between Xtext generated model and referred DomainModel [message #689114 is a reply to message #689101] |
Sun, 26 June 2011 21:30 |
|
Hi Christian,
I would have been pleasantly surprised if this had worked , I am sure I goofed up somewhere in the ResourceServiceProvider. I don't get anything either on ctrl+shift+f3 nor on ctrl+space in the editor.
Irrespective of that even if the domain model successfully exports the objects. Should not the xtext editor only show those model instances of the domain model to which it is bound.
In the sense, in my runtime workbench what would connect the new xtext file that I create (with my custom extension ".brDsl") to the domain model instance. Since I can create many instances of the domain model.
Thanks,
Best Regards,
Nidhi
|
|
|
|
|
Re: How to share model instanced between Xtext generated model and referred DomainModel [message #689128 is a reply to message #689125] |
Sun, 26 June 2011 22:46 |
|
Hi Christian,
It works and this time I am not sure how I just redid the whole thing again.
Phew! And thanks a tonne once again.
Now I have one more question , you had mentioned if I want to do some customization on top of this,
such as if the type attribute of my referenced entity "age" ([domainmodel :: Variable]) is "java.lang.Integer" the RHS of
"age > 18" should be an integer too. You mentioned that this needs to be done in the content assist itself.
Best Regards,
Nidhi
|
|
|
Powered by
FUDForum. Page generated in 0.03710 seconds