Skip to content

Commit 49460f5

Browse files
committed
EvlTask: add 'fix' field
1 parent 6ad5d25 commit 49460f5

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

examples/org.eclipse.epsilon.examples.eol.dap/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
<epsilon.emf.loadModel name="M"
4343
metamodelfile="epsilon/models/person.ecore"
4444
modelfile="epsilon/models/invalidPerson.model"
45-
read="true" store="false" />
45+
read="true" store="true" />
4646

47-
<epsilon.evl src="epsilon/09-validate.evl" debug="true" debugPort="4040" failOnErrors="false">
47+
<epsilon.evl src="epsilon/09-validate.evl" debug="true" debugPort="4040" failOnErrors="false" fix="true">
4848
<model ref="M"/>
4949
</epsilon.evl>
5050

plugins/org.eclipse.epsilon.evl.engine/src/org/eclipse/epsilon/evl/debug/EvlDebugger.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ protected boolean isStructuralBlock(ModuleElement ast) {
2727
@Override
2828
public boolean isDoneAfterModuleElement(ModuleElement ast) {
2929
if (super.isDoneAfterModuleElement(ast)) {
30+
if (getModule().getUnsatisfiedConstraintFixer() == null) {
31+
// There is no fixer to apply the fixes
32+
return true;
33+
}
34+
3035
for (UnsatisfiedConstraint unsatisfied : getModule().getContext().getUnsatisfiedConstraints()) {
3136
if (!unsatisfied.isFixed() && !unsatisfied.getFixes().isEmpty()) {
3237
// There is at least one unfixed unsatisfied constraint with fixes: leave it running

plugins/org.eclipse.epsilon.evl.engine/src/org/eclipse/epsilon/evl/execute/CommandLineFixer.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717

1818
public class CommandLineFixer implements IEvlFixer {
1919

20-
protected boolean fix = false;
21-
2220
@Override
2321
public void fix(IEvlModule module) throws EolRuntimeException {
2422
IEvlContext context = module.getContext();
2523
IUserInput userInput = context.getUserInput();
2624

2725
for (UnsatisfiedConstraint unsatisfiedConstraint : context.getUnsatisfiedConstraints()) {
2826
context.getOutputStream().println(unsatisfiedConstraint.getMessage());
29-
boolean fixIt = fix && (unsatisfiedConstraint.getFixes().size() > 0) && userInput.confirm("Fix error?", true);
27+
boolean fixIt = unsatisfiedConstraint.getFixes().size() > 0 && userInput.confirm("Fix error?", true);
3028

3129
if (fixIt) {
3230
FixInstance fixInstance = (FixInstance) userInput.choose(unsatisfiedConstraint.getMessage(), unsatisfiedConstraint.getFixes(), null);
@@ -37,12 +35,4 @@ public void fix(IEvlModule module) throws EolRuntimeException {
3735
}
3836
}
3937

40-
public boolean isFix() {
41-
return fix;
42-
}
43-
44-
public void setFix(boolean fix) {
45-
this.fix = fix;
46-
}
47-
4838
}

plugins/org.eclipse.epsilon.workflow/ant/org/eclipse/epsilon/workflow/tasks/EvlTask.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
public class EvlTask extends ExportableModuleTask {
2222

2323
protected String exportConstraintTrace;
24+
protected boolean fix = false;
2425

2526
public String getExportConstraintTrace() {
2627
return exportConstraintTrace;
@@ -31,7 +32,15 @@ public void setExportConstraintTrace(String exportConstraintTrace) {
3132
((IEvlModule) module).getContext().setOptimizeConstraintTrace(false);
3233
}
3334
}
34-
35+
36+
public boolean isFix() {
37+
return fix;
38+
}
39+
40+
public void setFix(boolean fix) {
41+
this.fix = fix;
42+
}
43+
3544
@Override
3645
protected IEvlModule createDefaultModule() {
3746
return new EvlModuleParallelAnnotation();
@@ -40,9 +49,10 @@ protected IEvlModule createDefaultModule() {
4049
@Override
4150
protected void initialize() throws Exception {
4251
IEvlModule evlModule = (IEvlModule) module;
43-
CommandLineFixer clf = new CommandLineFixer();
44-
clf.setFix(false);
45-
evlModule.setUnsatisfiedConstraintFixer(clf);
52+
if (isFix()) {
53+
CommandLineFixer clf = new CommandLineFixer();
54+
evlModule.setUnsatisfiedConstraintFixer(clf);
55+
}
4656
}
4757

4858
@Override

0 commit comments

Comments
 (0)