Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Quick fix for OCLinEcore (Quick fix for OCLinEcore )
Quick fix for OCLinEcore [message #1739930] Fri, 05 August 2016 18:00 Go to next message
Anetta van der Walt is currently offline Anetta van der WaltFriend
Messages: 3
Registered: August 2016
Junior Member
Hey,

I implemented constraint on a meta model level by making use of
OCLinEcore. Everything works perfectly and in my problem view I get an
error message if one of my constraints is violated.

However, now I would like to implement quick fixes for these
constraints in xtext. The only problem is I am not sure how to obtain
the unique identification/ID of each of the errors in order to link a
quick fix to it. Is there anybody who can advise me on this?

Thank you
Re: Quick fix for OCLinEcore [message #1739945 is a reply to message #1739930] Fri, 05 August 2016 19:01 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Quickfixes is one of many things on my todo list.

Currently the validation is done by typically
GIT\org.eclipse.ocl\plugins\org.eclipse.ocl.pivot\model\Pivot.ocl.

The underlying technology has been improved so that an invariant can
'return' a projection of a rich Tuple rather than just a Boolean. so you
could rewrite the Pivot.ocl constraints as e.g.

context IterateExp
inv SafeSourceCanBeNull:
isSafe implies not ownedSource?.type.oclAsType(CollectionType).isNullFree

as

context IterateExp
inv SafeSourceCanBeNull:
Tuple {
status : Boolean = isSafe implies not
ownedSource?.type.oclAsType(CollectionType).isNullFree,
message : String = 'Unnecessary safe navigation - the souc
collection is null-free',
quickfix : String = 'org.eclipse.ocl.pivot.ui.RemoveSafeNavigation'
}.status;

The rewrite should have little effect since naive use just ignores the
non-status fields. But a tweak to AbstractConstraintEvaluator or one of
its derivations should enable the code to activate the
org.eclipse.ocl.pivot.ui.RemoveSafeNavigation quickfix.

Alternatively a tweak to AbstractConstraintEvaluator or one of its
derivations should be able to use the invariant name as a key. You will
find that there is already support for per-constraint severity control
in the Window->Preferences-<>OCL->Unified Pivot Binding. If you look at
the generated code in IterateExp you can see

@Override
public boolean validateSafeIteratorIsRequired(final DiagnosticChain
diagnostics, final Map<Object, Object> context)
{
....
final /*@NonInvalid*/ org.eclipse.ocl.pivot.values.@NonNull
IntegerValue severity_0 =
CGStringGetSeverityOperation.INSTANCE.evaluate(executor,
PivotTables.STR_IterateExp_c_c_SafeIteratorIsRequired);

using PivotTables.STR_IterateExp_c_c_SafeIteratorIsRequired as a key to
lookup the severity.

If you fancy working on this please do. The auto-generation of Java from
QVTc / QVTr is getting close to useable, so I would like the quickfixes
to be QVTc / QVTr transformations. However for initial prototype
Java-coded transfornations will do fine.

Regards

Ed Willink

On 05/08/2016 19:00, Anetta van der Walt wrote:
> Hey,
>
> I implemented constraint on a meta model level by making use of
> OCLinEcore. Everything works perfectly and in my problem view I get an
> error message if one of my constraints is violated.
>
> However, now I would like to implement quick fixes for these constraints
> in xtext. The only problem is I am not sure how to obtain the unique
> identification/ID of each of the errors in order to link a quick fix to
> it. Is there anybody who can advise me on this?
>
> Thank you


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Previous Topic:NullPointerException after EMF Code Generation with OCL Constraints
Next Topic:Need your help on a student assignment .
Goto Forum:
  


Current Time: Fri Apr 26 02:46:41 GMT 2024

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

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

Back to the top