use of org.eclipse.xtext.ui.editor.model.edit.ICompositeModificationContext in project xtext-eclipse by eclipse.
the class QuickfixCrossrefTestLanguageQuickfixProvider method fixBadNames.
@SuppressWarnings("unchecked")
@Fix(QuickfixCrossrefTestLanguageValidator.BAD_NAME_IN_SUBELEMENTS)
public void fixBadNames(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.acceptMulti(issue, "Fix Bad Names", "Fix Bad Names", null, (Element main, ICompositeModificationContext<Element> ctx) -> {
ctx.addModification(main.eContainer(), c -> {
List<Element> siblings = (List<Element>) main.eContainer().eGet(main.eContainmentFeature());
int index = siblings.indexOf(main);
Element newEle = QuickfixCrossrefFactory.eINSTANCE.createElement();
newEle.setName("newElement");
siblings.add(index, newEle);
});
for (String s : issue.getData()[0].split(";")) {
EObject ele = main.eResource().getEObject(s);
Assert.assertTrue(ele instanceof Element);
ctx.addModification((Element) ele, e -> {
e.setName("goodname");
});
}
});
}
Aggregations