use of org.eclipse.xtext.ui.editor.quickfix.ReplaceModification in project xtext-eclipse by eclipse.
the class XbaseQuickfixProvider method fixAmbiguousMethodCall.
@Fix(IssueCodes.AMBIGUOUS_FEATURE_CALL)
public void fixAmbiguousMethodCall(final Issue issue, IssueResolutionAcceptor acceptor) {
String[] data = issue.getData();
if (data == null || data.length == 0) {
return;
}
for (String replacement : data) {
String replaceLabel = "Change to '" + replacement + "'";
acceptor.accept(issue, replaceLabel, replaceLabel, null, new ReplaceModification(issue, replacement));
}
}
use of org.eclipse.xtext.ui.editor.quickfix.ReplaceModification in project xtext-eclipse by eclipse.
the class JavaTypeQuickfixes method createResolution.
protected void createResolution(Issue issue, IssueResolutionAcceptor issueResolutionAcceptor, String issueString, IEObjectDescription solution) {
String replacement = qualifiedNameConverter.toString(solution.getName());
String replaceLabel = "Change to '" + replacement + "'";
issueResolutionAcceptor.accept(issue, replaceLabel, replaceLabel, null, new ReplaceModification(issue, replacement));
}
use of org.eclipse.xtext.ui.editor.quickfix.ReplaceModification in project xtext-eclipse by eclipse.
the class XbaseQuickfixProvider method fixRedundantCase.
@Fix(IssueCodes.REDUNDANT_CASE)
public void fixRedundantCase(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Remove redundant case.", "Remove redundant case.", null, new ReplaceModification(issue, ""));
acceptor.accept(issue, "Assign empty expression.", "Assign empty expression.", null, new ISemanticModification() {
@Override
public void apply(EObject element, IModificationContext context) throws Exception {
XSwitchExpression switchExpression = EcoreUtil2.getContainerOfType(element, XSwitchExpression.class);
if (switchExpression == null) {
return;
}
XCasePart casePart = IterableExtensions.last(switchExpression.getCases());
if (casePart == null || !(casePart.isFallThrough() && casePart.getThen() == null)) {
return;
}
List<INode> nodes = NodeModelUtils.findNodesForFeature(casePart, XbasePackage.Literals.XCASE_PART__FALL_THROUGH);
if (nodes.isEmpty()) {
return;
}
INode firstNode = IterableExtensions.head(nodes);
INode lastNode = IterableExtensions.last(nodes);
int offset = firstNode.getOffset();
int length = lastNode.getEndOffset() - offset;
ReplacingAppendable appendable = appendableFactory.create(context.getXtextDocument(), (XtextResource) element.eResource(), offset, length);
appendable.append(": {");
appendable.increaseIndentation().newLine();
appendable.decreaseIndentation().newLine().append("}");
appendable.commitChanges();
}
});
}
Aggregations