Can not gen emf-gen from ecore file based on generator (.mwe) of OCL open source [message #1848515] |
Mon, 06 December 2021 15:31 |
Nguyen Duc Dai Messages: 10 Registered: December 2021 |
Junior Member |
|
|
I am integrating OCL expression into my DSL that is the same as OclInEcore open source for final exam.
I hava git clone the OCL open source
First of all, i realize that GenerateCSModels.mwe2 in org.eclipse.ocl.examples.build source code which generate Concrete Syntax Models (it's located in the emf-gen folder) with the input file .genmodel.
With this GenerateCSModels.mwe2 file, the config path to .genmodel in oclinecore prj is normal. But I have created a new project, with my .genmodel file exactly the same as the .genmodel in oclinecore prj and I modify the config to my .genmodel in GenerateCSModels.mwe2 then run it i got the below error.
Prj I have created :"org.xtext.example.frsl" and the the location of .genmodel "model/custom/FRSL.genmodel". All config path are correct.
The img above is my .genmodel, which is the same as Oclinecore genmodel
Can someone help me? Please
My xtex: 2.25, Eclipse IDE: 2021-09 (4.21.0)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.emf.codegen.ecore.genmodel.GenAnnotation.getDetails()" because "ann" is null
at org.eclipse.ocl.examples.build.utilities.GenPackageHelper$VisitorGenModelAnnnotationManager.getVisitorClass(GenPackageHelper.java:57)
at org.eclipse.ocl.examples.build.utilities.GenPackageHelper$VisitorGenModelAnnnotationManager.getVisitorPackageName(GenPackageHelper.java:33)
at org.eclipse.ocl.examples.build.utilities.GenPackageHelper.getVisitorPackageName(GenPackageHelper.java:104)
at org.eclipse.ocl.examples.build.xtend.GenerateVisitorsWorkflowComponent.doPropertiesConfiguration(GenerateVisitorsWorkflowComponent.java:123)
at org.eclipse.ocl.examples.build.xtend.GenerateVisitorsWorkflowComponent.invokeInternal(GenerateVisitorsWorkflowComponent.java:206)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:133)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:35)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:213)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:38)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:38)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:21)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:103)
... 4 more
In my GenerateCSModel.mwe2, i just modified that:
module GenerateCSModels
import org.eclipse.ocl.examples.build.*
import org.eclipse.ocl.examples.build.utilities.*
import org.eclipse.ocl.examples.build.xtend.*
import org.eclipse.emf.mwe.utils.*
import org.eclipse.emf.mwe.utils.*
import org.eclipse.emf.ecore.resource.impl.*
/**
* Generate the Concrete Syntax Models used by the Xtext editors.
*/
Workflow {
bean = ResourceSetImpl : resourceSet {}
bean = StandaloneSetup { resourceSet = resourceSet
platformUri = ".."
scanClassPath = true
}
bean = EcoreGenModelSetup { resourceSet = resourceSet }
bean = UMLGenModelSetup { resourceSet = resourceSet }
component = @SubGenerateCSModel { resourceSet = resourceSet
projectName = "org.xtext.example.frsl"
genModelFile = "model/custom/FRSL.genmodel"
superProjectName = "org.eclipse.ocl.xtext.essentialocl"
superGenModelFile = "model/EssentialOCLCS.genmodel"
baseProjectName = "org.eclipse.ocl.xtext.base"
baseGenModelFile = "model/BaseCS.genmodel"
}
[Updated on: Tue, 07 December 2021 08:47] Report message to a moderator
|
|
|
|
|
|
|
Re: Can not gen emf-gen from ecore file [message #1848652 is a reply to message #1848642] |
Sun, 12 December 2021 15:19 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
If you debug the NPE, or just look at the crashing source code you will see that the problem is that "ann" is null because OCLGenModelUtil.OCL_GENMODEL_VISITOR_URI is missing. This is http://www.eclipse.org/OCL/GenModel/Visitor.
If you Google "OCL http://www.eclipse.org/OCL/GenModel/Visitor" (to avoid the bogus use of just "http://www.eclipse.org/OCL/GenModel/Visitor") you will get pointed at chapter 9 of the OCL documentation. "Building the OCL Project" , "GenModel GenAnnotations".
If you compare e.g. /org.eclipse.ocl.xtext.oclinecore/model/OCLinEcoreCS.genmodel with your frsl.genmodel you will see that you have omitted the GenAnnotatons that configure the MWE2 activoties. Since this is a build script I regard the close to the point NPE an adequate diagnosis.
I notice that your frsl.genmodel claims to be autogenerated by Xtext. I gave up on autogenerated ecore/genmodel years ago since they do not handle an adequate diversity of modeling use casesand IIRC use inconsistent references to other models. Always maintain your ecore/genmodel manually. .
Regards
Ed Willink
[Updated on: Sun, 12 December 2021 16:48] Report message to a moderator
|
|
|
|
|
|
Re: Can not gen emf-gen from ecore file [message #1848729 is a reply to message #1848712] |
Wed, 15 December 2021 08:44 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
There is a certain amount of documentation in the OCL documentation, but it is a while since I gave it a comprehensive review so many minor details may have evolved.
For the most part the xxxCS models correspond to the xxx.xtext grammar. Unfortunately the OCL grammar was badly designed, neglecting to use a yacc-like tool to detect ambiguities, consequently the tooling has to work very hard to accommodate the ambiguities. This is done by parsing to more general concepts such as NameExpCS and RoundBracketClauseCS so that the determination of the appropriate syntax can be deferred from the parser to the 'linker' where Containment, PreOrder, PostOrder,and LeftToRight CS Visitors elaborate the AS in a resolveable order. The parsing of the expressions handles the unpleasant precedence change for and/xor between OCL 2.0 and 2.2. Expressions are therefore parsed as a precedence free syntax tree that is re-interpreted once the modelled precedences of each node are known.
You have probably seen enough to see that there is considerable capability available, but that it is not easily available. Making it easy is one of my many Utopian roundtuits.
It is probably time to sit back and consider whether the pain of continuing to use the frame work is more or less than the pain of doing something else.
It is worth noting that Xbase is much better integrated with Xtext and provides Java-like rather than OCL-like expressions. Unless you really want the strong side-effect-free OCL semantics, you might give Xbase a try. However both Xbase and Eclipse OCL are now on the critical list in regards to their long term future.
Regards
Ed Willink
[Updated on: Wed, 15 December 2021 08:47] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03644 seconds