Reuse OCL - access Ecore metamodel entities in runtime [message #1822149] |
Fri, 28 February 2020 00:25 |
|
Hi,
Inspired from CompleteOCL, I've tried to reuse EssentialOCL grammar using Xtext mixin mechanism to create a new Xtext DSL. In the generated language, I have access to the OCL notations, such as "import", "context", "inv" and etc. But when I import a metamodel in the first line of a simple test of generated language (like to the OCL file),
import uml : 'http://www.eclipse.org/uml2/5.0.0/UML#/'
import graph : 'platform:/resource/TestProject/Graph.ecore#/'
context uml::Class
I haven't access to the imported metamodel entities and I get the following errors:
Quote:
Couldn't resolve reference to Element ''http://www.eclipse.org/uml2/5.0.0/UML#/''.
Couldn't resolve reference to Element ''platform:/resource/TestProject/Graph.ecore#/''.
Multiple markers at this line
- Couldn't resolve reference to Element 'uml'.
- Couldn't resolve reference to Element 'Class'.
In the new language, I need to access entities of different Ecore metamodels (similar to OCL). How can I fix these errors?
Regards,
Mohammadreza
|
|
|
|
Re: Reuse OCL - access Ecore metamodel entities in runtime [message #1822917 is a reply to message #1822154] |
Mon, 16 March 2020 18:04 |
|
Hi Ed,
Thanks for you comment,
I tried to add and initiate Base, Pivot, and Essential OCL Scope provider in my project with calling an OCLDelegate class in the mwe2 configuration file of Xtext project. But It didn't work yet and I get "Couldn't resolve reference to Element ..." error.
I've put a small example of my project in the following git repository.
https://github.com/MSharbaf/simpleExample
This repository contains the entire Xtext project and a test file (in TestGrammar/test1.mydsl) of the desired grammar. Could you please guide me how can I fix it?
Regards,
Mohammadreza
|
|
|
|
Re: Reuse OCL - access Ecore metamodel entities in runtime [message #1828057 is a reply to message #1822925] |
Sun, 31 May 2020 06:06 |
|
Hi,
After some searching and trying, I finally reused the OCL grammar and editor, in April.
Here are the most important things you need to do:
1- In your grammar, reuse the CompleteOCL grammar using mixin mechanism
2- In your grammar, import the BaseCS, EssentialCS, and CompleteOCL URI
3- In your main Xtext project, Add the OCLDelegateSetup.java for initializing Base, Essential, and CompleteOCL scoping.
4- In the scoping folder of your Xtext project, you need to extend EssentialScopeProvider
5 - In your Xtext project, you need to add a ResourceDescriptionStrategy.xtend that extended DefaultResourceDescriptionStrategy
6- In the AbstractRuntimeModule of your main Xtext project, you should add some EssentialOCLFragment
7- Some elements of your model object, which created based on your grammar, should extend CompleteOCL (in both abstraction and implementation java files)
Best regards,
Mohammadreza
|
|
|
|
Powered by
FUDForum. Page generated in 0.03178 seconds