| Custom validation failure messages [message #671951] |
Thu, 19 May 2011 08:43  |
Darie Moldovan Messages: 67 Registered: November 2010 Location: Darmstadt, Germany |
Member |
|
|
Hi,
after reading the discussion here, I tried the feature of defining custom messages for the validation myself. Although I followed the steps mentioned there, I still didn't get to see my message when constraints are violated.
I checked this bug and read pages 87-88 from this presentation, to be sure I'm not omitting something. The custom messages are simply not shown in my xtext editor.
Here's what I tried: after defining an invariant, I wanted to show a custom message when the validation returns an error, something like (in oclinecore)
invariant OrdinalIsUnique('Ordinals must be unique.'):
ElemA.allInstances()->excluding(self).ordinal->excludes(ordinal);
or, in Ecore
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
<details key="OrdinalIsUnique" value="(((ElemA.allInstances())->excluding(self))->collect(ordinal))->excludes(ordinal)"/>
<details key="OrdinalIsUnique$message" value="'Ordinals must be unique.'"/>
</eAnnotations>
but the custom message is not shown in the xtext editor. If I define
ElemA one (
ordinal 0
)
ElemA two (
ordinal 1
)
ElemA three(
ordinal 0 // not valid, according to the invariant
)
the marker is shown at the right line and the validation returns the following error:
The 'OrdinalIsUnique' constraint is violated on 'MyDSL.impl.ElemAImpl @ 677646{platform:/resource/TestOCLXtext2/src/basic.MyDSL#//@elements.0}'
which is correct, because the constraint is, indeed, violated. But why isn't my message shown? As I said, my generated validator inherits OCLinEcoreEObjectValidator, I checked that the class is not generated and I added org.eclipse.ocl.examples.xtext.oclinecore as a dependency in the manifest. In my case, it does not work.
Tested with:
Eclipse Indigo Build id: 20110505-1223
Xtext 2.0.0.v201105170444
OCL 3.1.0.v20110502-1445
Any clues why this might still not work?
Thanks in advance.
Darie
|
|
|
|
|
|
|
|
|
|
| Re: Custom validation failure messages [message #1059449 is a reply to message #672370] |
Sat, 18 May 2013 13:20  |
|
Ed Willink wrote on Fri, 20 May 2011 17:38
@Override
public void configure(Binder binder) {
super.configure(binder);
binder.bindConstant().annotatedWith(Names.named(org.eclipse.xtext.validation.CompositeEValidator.USE_EOBJECT_VALIDATOR)).to(false);
}
Is it still valid on Juno SR2? I can't make it work with the following tooling, and can't find out if it's either incompatibility or a silly mistake:
* Eclipse Juno
Version: 4.2.2
Build id: M20130204-1200
* Eclipse Modeling Framework Runtime and Tools
Version: 2.8.3.v20130125-0826
Build id: R201301250826
* Xtext SDK
Version: 2.4.1.v201304180855
* OCL (Object Constraint Language)
Version: 3.2.2.v20130128-1158
Build id: M201301281158
The source code (and more details) is available at this github repo: https://github.com/juniorz/playing-with-eclipse-mdt
Thanks for any help!
|
|
|
Powered by
FUDForum. Page generated in 0.01742 seconds