|
Re: Quick fix for OCLinEcore [message #1739945 is a reply to message #1739930] |
Fri, 05 August 2016 19:01 |
Ed Willink 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
|
|
|
Powered by
FUDForum. Page generated in 0.02889 seconds