Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Complete OCL for Xtext Validation(Change in methods from the tutorials and documentation)
Complete OCL for Xtext Validation [message #1777951] Wed, 06 December 2017 16:43 Go to next message
David  Riobó is currently offline David RiobóFriend
Messages: 9
Registered: August 2017
Junior Member
Hello!

I am trying to integrate external ocl constraints in my Xtext editor and for that matter I tried to follow the OCL tutorial, in specific the Complete OCL for Xtext Validation section.

However, this code

public class StatesJavaValidator extends AbstractStatesJavaValidator
{
 @Override
 public void register(EValidatorRegistrar registrar) {
 super.register(registrar);
 StatesPackage ePackage = StatesPackage.eINSTANCE;
 URI oclURI = URI.createPlatformResourceURI(
 "/StatesProject/model/States.ocl", true);
 registrar.register(ePackage,
 new CompleteOCLEObjectValidator(ePackage, oclURI));
 }
}


is no longer valid since CompleteOCLEObjectValidator needs an EnvironmentFactory. I have tried several options but I always end with a

!ENTRY org.eclipse.ocl.xtext.base 4 0 2017-12-06 17:25:17.867
!MESSAGE Essential OCL Editor linking error
!STACK 0
java.lang.NullPointerException
at org.eclipse.ocl.pivot.internal.manager.Orphanage.getOrphanage(Orphanage.java:400)
at org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.createOrphanage(PivotMetamodelManager.java:528)
at org.eclipse.ocl.pivot.internal.CompleteModelImpl.getOrphanage(CompleteModelImpl.java:577)
at org.eclipse.ocl.xtext.base.cs2as.CS2ASConversion.garbageCollect(CS2ASConversion.java:325)
at org.eclipse.ocl.xtext.base.cs2as.CS2AS.update(CS2AS.java:635)
at org.eclipse.ocl.xtext.base.utilities.CS2ASLinker.afterModelLinked(CS2ASLinker.java:84)
at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:57)
at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:340)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:107)
at org.eclipse.ocl.xtext.essentialocl.utilities.EssentialOCLCSResource.doLinking(EssentialOCLCSResource.java:346)
at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:301)
at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:290)
at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:180)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:100)
at org.eclipse.ocl.xtext.essentialocl.utilities.EssentialOCLCSResource.doLoad(EssentialOCLCSResource.java:354)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.ocl.pivot.internal.context.AbstractParserContext.createBaseResource(AbstractParserContext.java:77)
at org.eclipse.ocl.pivot.internal.context.AbstractParserContext.parse(AbstractParserContext.java:150)
at org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.parseSpecification(PivotMetamodelManager.java:2146)
at org.eclipse.ocl.pivot.internal.delegate.ValidationBehavior.getQueryOrThrow(ValidationBehavior.java:115)
at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate.validatePivot(OCLValidationDelegate.java:310)
at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate.validate(OCLValidationDelegate.java:239)
at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegateFactory.validate(OCLValidationDelegateFactory.java:77)
at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:227)
at org.avl.mdml.mydsl.mDML04.util.MDML04Validator.validateDevice_MinStatevars(MDML04Validator.java:248)
at org.avl.mdml.mydsl.mDML04.util.MDML04Validator.validateDevice(MDML04Validator.java:197)
at org.avl.mdml.mydsl.mDML04.util.MDML04Validator.validate(MDML04Validator.java:92)
at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:324)
at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:181)
at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:70)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:120)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:146)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:124)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(DefaultResourceUIValidatorExtension.java:60)
at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(DefaultResourceUIValidatorExtension.java:46)
at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.processDelta(MarkerUpdaterImpl.java:93)
at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.updateMarkers(MarkerUpdaterImpl.java:63)
at org.eclipse.xtext.builder.builderState.AbstractBuilderState.updateMarkers(AbstractBuilderState.java:82)
at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:283)
at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:287)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:267)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:161)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Does anyone have an example of how to proceed with the new version? It would be much appreciated. Thanks!
Re: Complete OCL for Xtext Validation [message #1777961 is a reply to message #1777951] Wed, 06 December 2017 20:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5977
Registered: July 2009
Senior Member
Hi

Thanks. Oops. https://bugs.eclipse.org/bugs/show_bug.cgi?id=528220 raised.

For now you should be able to add

org.eclipse.ocl.pivot.utilities.OCL.newInstance().getEnvironmentFactory()

to provide the missing third argument.

Regards

Ed Willink
Re: Complete OCL for Xtext Validation [message #1778280 is a reply to message #1777961] Tue, 12 December 2017 15:31 Go to previous messageGo to next message
David  Riobó is currently offline David RiobóFriend
Messages: 9
Registered: August 2017
Junior Member
Hi back,

I'm sorry I didn't reply before but I am having extra problems.

The point here is to add OCL constraints to a certain DSL created in Xtext and to use this constraints in the editor of the new plugin (standalone product in this case).

That line works without any problem but now I get a

Description Resource Path Location Type
An exception occurred while delegating evaluation of the 'MinInputs' constraint on 'org.avl.mdml.mydsl.mDML04.impl.DeviceImpl@48777b76{platform:/resource/MyMDMLProject/src/Untitled.mdml#//@device}': java.lang.IllegalStateException: No 'http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot' ValidationDelegate for 'org.avl.mdml.mydsl.mDML04.impl.DeviceImpl@48777b76{platform:/resource/MyMDMLProject/src/Untitled.mdml#//@device}' Untitled.mdml /MyMDMLProject/src line: 1 /MyMDMLProject/src/Untitled.mdml Xtext Check (fast)

I can imagine there is a problem between the constraints defined in ECore and the ones I am defining in the OCL. Is it something like that? There is a certain other approach I should take when trying to add the OCL Validator here? I am extending the DSL validator generated with Xtext and registering it with the code you wrote before.

I am a pretty new user of the framework so I apologize for any obvious mistakes I'm making :)

Re: Complete OCL for Xtext Validation [message #1778285 is a reply to message #1778280] Tue, 12 December 2017 16:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5977
Registered: July 2009
Senior Member
Hi

These problems look familiar from many development pains, but I tried to ensure that PivotStandaloneSetup.doSetup() makes everything painless. Without a repro and identified OCL versions I cannot tell whether you have found a new form of pain or whether you have neglected to use the latest fixes. See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Complete OCL for Xtext Validation [message #1778377 is a reply to message #1778285] Wed, 13 December 2017 14:56 Go to previous messageGo to next message
David  Riobó is currently offline David RiobóFriend
Messages: 9
Registered: August 2017
Junior Member
Well, I want to apologize for the "harsh" post anyways. It was indeed a problem of my setup and now everything works fine.

My only concern now would be that I am using

org.eclipse.ocl.xetx.completeocl 1.1.0

org.eclipse.ocl.xtext.oclstdlib 1.1.0

and org.eclipse.ocl 3.6.0

defined in my MANIFEST.MF because, if I remember correctly, when trying to use the latest version offered from the Eclipse repository the org.eclipse.pde.runtime plug-in would disappear from the target platform so it would stop being accessible from the MANIFEST. I managed this by taking a different version of the OCL, previous one, and now everything works as expected (or it appears so). Just wanted to pointed it out, perhaps there is a compatibility problem with the latest version? I don't know. Maybe another problem with my target since it's pretty big. Not important now.

In any case thank you very much for the help! It was really fast and on point. I will try to be clearer next time I encounter problems here.

Best,

David
Re: Complete OCL for Xtext Validation [message #1778379 is a reply to message #1778377] Wed, 13 December 2017 15:12 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5977
Registered: July 2009
Senior Member
Hi

Recent Eclipse platform changes have added both Java 9 and JUnit 5 support for both Oxygen.1a and Photon M2. A month or two ago a number of users managed to get into trouble, sometimes clearly due to a failure to read Java 9 guidance, but sometimes for less obvious reasons. Mismatching PDE and JDT versions were a common symptom. The problems seem to have subsided. Perhaps you are experiencing one of these bleeding edge PDE phenomena.

OCL has very few platform dependencies. It used to work on four successive annual releases, but the advent of Java 8 and now Java 9 has made multi-version support very hard. So long as you only use Java 8 all should be ok, however the platform developers are working very hard on Java 9 and occasionally they need a Bugzilla to identify a Java 8 compatibility. If you have a repro maybe you can identify just such a Bugzilla.

If you are using org.eclipse.ocl.xtext... you are using the Xtext support from the Pivot-based OCL. You should therefore be using org.eclipse.ocl.pivot... for the model rather than org.eclipse.ocl.{ecore, uml} to avoid inconsistencies.

Regards

Ed Willink

Previous Topic:Let expression in OCL without specifying type
Next Topic:Migrating from CompleteOCL to OCLinEcore
Goto Forum:
  


Current Time: Thu Jul 19 15:09:33 GMT 2018

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

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

Back to the top