Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Can not gen emf-gen from ecore file based on generator (.mwe) of OCL open source(Can not gen emf-gen from ecore file based on generator (.mwe) of OCL open source)
Can not gen emf-gen from ecore file based on generator (.mwe) of OCL open source [message #1848515] Mon, 06 December 2021 15:31 Go to next message
Nguyen Duc Dai is currently offline Nguyen Duc DaiFriend
Messages: 10
Registered: December 2021
Junior Member
index.php/fa/41430/0/

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 #1848530 is a reply to message #1848515] Tue, 07 December 2021 05:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

If you want to help yourself, make smaller and smaller steps from what works to what you want so that you can determine what you do wrong. (The OCL OOMPH set has been recently refreshed so use an installation cincatining all three parts of the OCL project.)

If you want help follow https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Can not gen emf-gen from ecore file [message #1848538 is a reply to message #1848530] Tue, 07 December 2021 08:49 Go to previous messageGo to next message
Nguyen Duc Dai is currently offline Nguyen Duc DaiFriend
Messages: 10
Registered: December 2021
Junior Member
Hi sir,

I really want help, I have followed and described my context more detail.

Is it clear enough?

Regards,

[Updated on: Tue, 07 December 2021 08:50]

Report message to a moderator

Re: Can not gen emf-gen from ecore file [message #1848559 is a reply to message #1848538] Tue, 07 December 2021 19:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

No

Because you haven't provided any of the files that are causing trouble, I cannot investigate. I can only guess that you have an inappropriate reference in your Ecore file.

Regards

Ed Willink
Re: Can not gen emf-gen from ecore file [message #1848642 is a reply to message #1848559] Sat, 11 December 2021 18:23 Go to previous messageGo to next message
Nguyen Duc Dai is currently offline Nguyen Duc DaiFriend
Messages: 10
Registered: December 2021
Junior Member
Hi sir,

This is my essential code zip.

Please help me find the specific cause of the problem

To run this code zip ... I think you need to import OCL via oomph (with development and build+test option) then compare with my code to the corresponding map

I have modified ONLY the GenerateCSModels.mwe2 in the available org.eclipse.ocl.examples.build prj to config path to my .genmodel in my frsl prj

And i run GenerateCSModels.mwe2, it get error ... But when t comment the config to my prj and uncomment the config to OCLInecore path --> it work.

NOTE: my frsl.genmodel and oclinecore.genmodel is the same

I dont know why

I need your help, please !!!

Regards,
Dai
  • Attachment: Test.zip
    (Size: 6.13MB, Downloaded 109 times)
Re: Can not gen emf-gen from ecore file [message #1848652 is a reply to message #1848642] Sun, 12 December 2021 15:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
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 #1848659 is a reply to message #1848652] Mon, 13 December 2021 07:28 Go to previous messageGo to next message
Nguyen Duc Dai is currently offline Nguyen Duc DaiFriend
Messages: 10
Registered: December 2021
Junior Member
Hi sir,

Oh it is true that i am missing xmi genAnnotation when i open frsl.genmodel with text.

I can't find how to add genAnnotation with EDITOR of .genmodel. I have to add by xmi code, Right ?

Regards,
Dai

[Updated on: Mon, 13 December 2021 07:31]

Report message to a moderator

Re: Can not gen emf-gen from ecore file [message #1848661 is a reply to message #1848659] Mon, 13 December 2021 08:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

Fort multi-line edits I often resort to a text editor, yes.

But if you have checked Show GenAnnotations in the main tool bar Generate menu, you can see and edit GenAnnotations just like anything else. It is far from clear why the default is so unhelpful. Most users have no GenAnnotations so don't; those with GenAnnotations can be confused.

Regards

Ed Willink
Re: Can not gen emf-gen from ecore file [message #1848712 is a reply to message #1848661] Tue, 14 December 2021 18:28 Go to previous messageGo to next message
Nguyen Duc Dai is currently offline Nguyen Duc DaiFriend
Messages: 10
Registered: December 2021
Junior Member
Hi sir,

Many thanks for your replies,

I have a few questions which t need your help,

Is there any information / doc about BaseCS metamodel and which metaconcept I should use for only EXPRESSION ocl ???

Thanks for taking the time

Regards,
Dai
Re: Can not gen emf-gen from ecore file [message #1848729 is a reply to message #1848712] Wed, 15 December 2021 08:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
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

Previous Topic:Getting invalid for the evaluation of OCL on XMI
Next Topic:Get annotations from type rather than instance
Goto Forum:
  


Current Time: Mon Jul 22 15:26:06 GMT 2024

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

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

Back to the top