Skip to content

Commit

Permalink
194: clone the expression when moving
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Jun 15, 2020
1 parent 996ec01 commit 9822d8e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static edelta.util.EdeltaModelUtil.getContainingBlockXExpression;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext;
import org.eclipse.xtext.ui.editor.quickfix.Fix;
Expand Down Expand Up @@ -123,7 +124,14 @@ public void moveToRightPosition(final Issue issue, final IssueResolutionAcceptor
sourceBlock.getExpressions().remove(blockExp);
var responsibleExpressionPosition =
expressions.indexOf(responsibleExpressionBlockExp);
expressions.add(responsibleExpressionPosition + 1, blockExp);
/*
* it is crucial to copy the expression otherwise the formatter
* will not be able to format the code correctly, resulting in
* syntax errors after formatting (the expressions will not be
* separated)
*/
expressions.add(responsibleExpressionPosition + 1,
EcoreUtil.copy(blockExp));
}
);
}
Expand Down

0 comments on commit 9822d8e

Please sign in to comment.