Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom DSL with OCL constraints(Creating a DSL with embedded OCL constraints at instance level (OCL integration in grammar problem))
icon5.gif  Custom DSL with OCL constraints [message #917983] Thu, 20 September 2012 16:10
Arnaud Dieumegard is currently offline Arnaud DieumegardFriend
Messages: 29
Registered: June 2010
Junior Member
Hi all,

I'm working at embedding OCL expression in my DSL.
In order to do that I looked at CompleteOCL and inspire myself from it.
So I have a Grammar like this one (this is an extract):

grammar org.eclipse.formalBlockSpecification.Fbs 
with org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST" as essentialOCL
import "http://www.eclipse.org/formalBlockSpecification/Fbs"

BlockLibrary returns BlockLibrary:
	'library' name=ID ('imports' imports+=[BlockLibrary] ( ',' imports+=[BlockLibrary])*)?'{'
	(types+=TypeDefinition | blocks+=BlockType)*
	'}'
;

[...]

OCLInvariantCS returns OCLInvariantCS: 
	'invariant' name=ID ':' specification=OCLExpression
;

OCLSpecificationCS returns OCLSpecificationCS: 
	'specification' name=ID stereotype=SPECIFICATION_KIND ':' specification=OCLExpression
;

OCLExpression returns ContextSpecificationCS: 
	ownedExpression=ExpCS
;

terminal SPECIFICATION_KIND:
	"type_checking"
	| "forward_type_inference"
	| "backward_type_inference"
	| "memory_initialization"
	| "output_computation"
	| "memory_update"
;
	


I have the corresponding ecore model. I have to explains some things about the last rules:
OCLInvariantCS extends ConstraintCS from BaseCST
OCLSpecificationCS extends ConstraintCS from BaseCST
ContextSpecificationCS extends ExpSpecificationCS from essentialOCL
ExpCS is from essentialOCL

In the workflow I added the necessary elements:

Workflow {
    bean = StandaloneSetup {
            scanClassPath = true
            platformUri = "${runtimeProject}/.."
	    registerGeneratedEPackage = "org.eclipse.ocl.examples.xtext.base.baseCST.BaseCSTPackage"
	    registerGeneratedEPackage = "org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.EssentialOCLCSTPackage"
	    registerGeneratedEPackage = "org.eclipse.formalBlockSpecification.fbs.FbsPackage"
	    registerGenModelFile = "platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.genmodel"
	    registerGenModelFile = "platform:/resource/org.eclipse.ocl.examples.xtext.essentialocl/model/EssentialOCLCST.genmodel"
	    registerGenModelFile = "platform:/resource/org.eclipse.formalBlockSpecification/model/Fbs.genmodel"
        }

[...]


I have imported in my workspace the following projects:
org.eclipse.ocl.examples.pivot
org.eclipse.examples.xtext.base
org.eclipse.ocl.examples.xtext.essentialocl
In order to try what is stated here: http://www.eclipse.org/forums/index.php/t/373485/ about the platform:/resource

When I launch the workflow I have an error:

0    [Thread-1] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering platform uri '/Users/arnauddieumegard/Documents/Dev/eclipse/ws-BLJuno'
407  [Thread-1] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.ocl.examples.xtext.base.baseCST.BaseCSTPackage'
450  [Thread-1] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.EssentialOCLCSTPackage'
469  [Thread-1] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.formalBlockSpecification.fbs.FbsPackage'
1098 [Thread-1] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/ocl/3.1.0/BaseCST' from 'platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.genmodel'
1136 [Thread-1] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST' from 'platform:/resource/org.eclipse.ocl.examples.xtext.essentialocl/model/EssentialOCLCST.genmodel'
1161 [Thread-1] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/formalBlockSpecification/Fbs' from 'platform:/resource/org.eclipse.formalBlockSpecification/model/Fbs.genmodel'
2346 [Thread-1] ERROR ipse.xtext.generator.LanguageConfig  - [TransformationDiagnostic: null:155 Cannot find compatible feature ownedExpression in sealed EClass ContextSpecificationCS from imported package http://www.eclipse.org/formalBlockSpecification/Fbs: The existing reference 'ownedExpression' has an incompatible type 'ExpCS' [org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.ExpCS]. The expected type is 'ExpCS'. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
2350 [Thread-1] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems instantiating module org.eclipse.formalBlockSpecification.GenerateFbs: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: Problems instantiating module org.eclipse.formalBlockSpecification.GenerateFbs: java.lang.reflect.InvocationTargetException
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:95)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.reflect.InvocationTargetException
	at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:143)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:142)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:142)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:80)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:93)
	... 4 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:54)
	... 37 more
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/eclipse/formalBlockSpecification/Fbs.xtext':[TransformationDiagnostic: null:155 Cannot find compatible feature ownedExpression in sealed EClass ContextSpecificationCS from imported package http://www.eclipse.org/formalBlockSpecification/Fbs: The existing reference 'ownedExpression' has an incompatible type 'ExpCS' [org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.ExpCS]. The expected type is 'ExpCS'. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
	at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:190)
	... 42 more



I must say that I do not understand the: Quote:
The existing reference 'ownedExpression' has an incompatible type 'ExpCS' [org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.ExpCS] The expected type is 'ExpCS'

It's quite weird as it seems to be the same type.

I'm using:
Xtext SDK 2.3.1.v20120821
Eclipse Version: Juno Release
Build id: 20120614-1722
On a MacOS 10.6 computer.

Does anyone know what is happening here ?

Thanks,
Arnaud

[Updated on: Thu, 20 September 2012 16:10]

Report message to a moderator

Previous Topic:Renaming cross links
Next Topic:Large Files slows the Editor
Goto Forum:
  


Current Time: Fri Mar 29 07:29:30 GMT 2024

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

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

Back to the top