[ACCELEO] Using OCL Invocation and Setting delegates [message #813979] |
Mon, 05 March 2012 17:45  |
Eclipse User |
|
|
|
Hi,
I have a EMF model that I edited with OCLInEcore. In this model I use a lot derived properties and operations that are implemented using OCL (Pivot metamodel). When I use the model manually it all works fine, but when I use it in ACCELEO the derive properties and operations does not work.
I do the standalone setup:
// initialize OCL
OCLinEcoreStandaloneSetup.doSetup()
OCLstdlib.install()
OCL.initialize(null)
// initialize OCL delegation
val oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE +=
(oclDelegateURI -> new OCLInvocationDelegateFactory.Global())
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE +=
(oclDelegateURI -> new OCLSettingDelegateFactory.Global());
EValidator.ValidationDelegate.Registry.INSTANCE +=
(oclDelegateURI -> new OCLValidationDelegateFactory.Global())
Before I invoke the doGenerate() method from ACCELEO I can navigate through the model using the OCL implemented properties and invoke OCL implemented operations, but when I access a derived property I get:
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 87 in Module main for block for (controlSystem.mainComposites). Last recorded value of self was fr.unice.salty.core.model.salty.impl.ControlSystemImpl@2857a293.
at main.main(ControlSystem)(main.mtl:87)
at main.main(ControlSystem)(main.mtl:83)
If I put a breakpoint to the method that encapsulates this property - the method that has been generated by the genmodel it is not called.
Is this supported in ACCELEO? What do I need to setup in order to have it working?
Thanks a lot for help
Filip
|
|
|
|
|
|
|
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815060 is a reply to message #814835] |
Wed, 07 March 2012 02:13   |
Eclipse User |
|
|
|
Hi
This issue is nothing to do with the new Pivot model.
[The editing activities use the Pivot model and persist the OCL
expression as a String within an EAnnotation. When Acceleo runs, the OCL
string is processed by the legacy Ecore support.]
Acceleo does use the generated method; it just gets a parse error while
doing so.
There is a good chance that changing line 111 of
org.eclipse.acceleo.engine.internal.environment.AcceleoEnvironmentFactory from
AcceleoEnvironment result = new
AcceleoEnvironment(getEPackageRegistry());
to
AcceleoEnvironment result = new AcceleoEnvironment(parent);
and introducing the missing constructor
protected AcceleoEnvironment(Environment<EPackage, EClassifier,
EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject,
CallOperationAction, SendSignalAction, Constraint, EClass, EObject>
parent) {
super(parent);
}
will cure the problem.
Perhaps someone from Obeo can be more helpful.
Regards
Ed Willink
On 06/03/2012 23:35, Filip Krikava wrote:
> Hi,
>
> Thanks a lot for such a fat response. That is very unfortunate (I
> guess that even if the self was not hidden if it interprets OCL it
> will not likely use the Pivot meta-model, right?).
>
> I just don't understand why Acceleo does not use the generated java
> method? I mean if I add and operation or derived property that I
> implement manually in java it will work. Would it be possible to
> change the behavior so it does use it? I would be more than happy to
> hack it somehow if I knew where :).
> I cannot change to Juno and I'd love to have the project be built on
> the OMG stds rather than some other M2T toolkit :)
>
> /cheers
> Filip
|
|
|
|
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815151 is a reply to message #815129] |
Wed, 07 March 2012 04:39   |
Eclipse User |
|
|
|
Hi Laurent
When I run the attached launch config on 3.7.2, I get
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
iteration at line 14 in Module main for block for (system.allTested).
Last recorded value of self was
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@16614e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@16546ef (name: System)
(instanceClassName: null) (abstract: false, interface: false)). Problem
found while generating the file
'C:\Development\Admin\Workspace3.6\ocltest3\output\system.txt'.
at main.main(System)(main.mtl:14)
at main.main(System)(main.mtl:7)
at main.main(System)(main.mtl:4)
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
iteration at line 18 in Module main for block for
(system.allTestedNames). Last recorded value of self was
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@16614e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@16546ef (name: System)
(instanceClassName: null) (abstract: false, interface: false)). Problem
found while generating the file
'C:\Development\Admin\Workspace3.6\ocltest3\output\system.txt'.
at main.main(System)(main.mtl:18)
at main.main(System)(main.mtl:7)
at main.main(System)(main.mtl:4)
If you run with a Breakpoint on NPE you will see the underlying failure
to resolve 'self' that causes a ParseException that causes the eventual
diagnostic.
Regards
Ed
On 07/03/2012 09:10, Laurent Goubet wrote:
> Ed, Filip,
>
> What exactly am I to test here? If I launch the provided unit test
> with Helios :
>
> - as JUnit test : testStandalone fails, testMTT is in error (as the
> template's first parameter is a proxy, I suppose due to
> testStandalone's failure.
> - as JUnit plug-in test : testStandalone fails, testMTT passes.
>
> testStandalone's failure is the same for both runs :
>
> arrays first differed at element [0]; expected:<[B]> but was:<[C]>
> at
> org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:52)
> at org.junit.Assert.internalArrayEquals(Assert.java:414)
> at org.junit.Assert.assertArrayEquals(Assert.java:166)
> at org.junit.Assert.assertArrayEquals(Assert.java:183)
> at Tests.testStandalone(Tests.java:44)
>
> I'll try and launch the Acceleo generator itself, but here are my
> results with the unit test.
>
> Laurent Goubet
> Obeo
Attachment: Main.launch
(Size: 1.32KB, Downloaded 359 times)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816238 is a reply to message #816224] |
Thu, 08 March 2012 10:37  |
Eclipse User |
|
|
|
Hi Ed,
That is true, adding parent as a regular reference will fix this particular problem, but in this case it will make the model parser more difficult. Anyway, I might be facing similar issue later that will be due the the difference between Pivot and the regular OCL meta-model like when I would use oclContents() or something. That's why I think making the change that will prevent Acceleo (and potentially other tools) to evaluate expression that was not meant for them will fix the problem.
/cheers
Filip
|
|
|
Powered by
FUDForum. Page generated in 0.05777 seconds