use of org.eclipse.xtext.ui.editor.model.edit.IModification in project xtext-xtend by eclipse.
the class CreateXtendTypeQuickfixes method newXtendInterfaceQuickfix.
protected void newXtendInterfaceQuickfix(final String typeName, final String explicitPackage, final XtextResource resource, Issue issue, IssueResolutionAcceptor issueResolutionAcceptor) {
String packageDescription = getPackageDescription(explicitPackage);
issueResolutionAcceptor.accept(issue, "Create Xtend interface '" + typeName + "'" + packageDescription, "Opens the new Xtend interface wizard to create the type '" + typeName + "'" + packageDescription, "xtend_file.png", new IModification() {
@Override
public void apply(/* @Nullable */
IModificationContext context) throws Exception {
runAsyncInDisplayThread(new Runnable() {
@Override
public void run() {
NewElementWizard newXtendInterfaceWizard = newXtendInterfaceWizardProvider.get();
WizardDialog dialog = createWizardDialog(newXtendInterfaceWizard);
NewXtendInterfaceWizardPage page = (NewXtendInterfaceWizardPage) newXtendInterfaceWizard.getStartingPage();
configureWizardPage(page, resource.getURI(), typeName, explicitPackage);
dialog.open();
}
});
}
});
}
use of org.eclipse.xtext.ui.editor.model.edit.IModification in project xtext-xtend by eclipse.
the class CreateXtendTypeQuickfixes method newXtendClassQuickfix.
protected void newXtendClassQuickfix(final String typeName, final String explicitPackage, final XtextResource resource, Issue issue, IssueResolutionAcceptor issueResolutionAcceptor) {
String packageDescription = getPackageDescription(explicitPackage);
issueResolutionAcceptor.accept(issue, "Create Xtend class '" + typeName + "'" + packageDescription, "Opens the new Xtend class wizard to create the type '" + typeName + "'" + packageDescription, "xtend_file.png", new IModification() {
@Override
public void apply(/* @Nullable */
IModificationContext context) throws Exception {
runAsyncInDisplayThread(new Runnable() {
@Override
public void run() {
NewElementWizard newXtendClassWizard = newXtendClassWizardProvider.get();
WizardDialog dialog = createWizardDialog(newXtendClassWizard);
NewXtendClassWizardPage page = (NewXtendClassWizardPage) newXtendClassWizard.getStartingPage();
configureWizardPage(page, resource.getURI(), typeName, explicitPackage);
dialog.open();
}
});
}
});
}
use of org.eclipse.xtext.ui.editor.model.edit.IModification in project xtext-eclipse by eclipse.
the class DomainmodelQuickfixProvider method fixTypeName.
@Fix(IssueCodes.INVALID_TYPE_NAME)
public void fixTypeName(final Issue issue, final IssueResolutionAcceptor acceptor) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Capitalize name of \'");
String _get = issue.getData()[0];
_builder.append(_get);
_builder.append("\'");
final IModification _function = (IModificationContext context) -> {
IXtextDocument xtextDocument = context.getXtextDocument();
String firstLetter = xtextDocument.get((issue.getOffset()).intValue(), 1);
xtextDocument.replace((issue.getOffset()).intValue(), 1, Strings.toFirstUpper(firstLetter));
};
acceptor.accept(issue, "Capitalize name", _builder.toString(), "upcase.png", _function);
}
use of org.eclipse.xtext.ui.editor.model.edit.IModification in project xtext-eclipse by eclipse.
the class XbaseQuickfixProvider method fixTypeArguments.
@Fix(IssueCodes.INVALID_TYPE_ARGUMENTS_ON_TYPE_LITERAL)
public void fixTypeArguments(final Issue issue, IssueResolutionAcceptor acceptor) {
String message = issue.getMessage();
String fixup = "Remove invalid type arguments";
if (message.contains("argument.")) {
fixup = "Remove invalid type argument";
}
acceptor.accept(issue, fixup, fixup, null, new IModification() {
@Override
public void apply(IModificationContext context) throws Exception {
IXtextDocument document = context.getXtextDocument();
document.replace(issue.getOffset(), issue.getLength(), "");
}
});
}
use of org.eclipse.xtext.ui.editor.model.edit.IModification in project xtext-eclipse by eclipse.
the class XbaseQuickfixProvider method fixEqualsWithNull.
@Fix(IssueCodes.EQUALS_WITH_NULL)
public void fixEqualsWithNull(final Issue issue, IssueResolutionAcceptor acceptor) {
String[] data = issue.getData();
if (data == null || data.length == 0) {
return;
}
String operator = data[0];
String message = "Replace '" + operator + "' with '" + operator + "='";
acceptor.accept(issue, message, message, null, new IModification() {
@Override
public void apply(IModificationContext context) throws Exception {
IXtextDocument document = context.getXtextDocument();
document.replace(issue.getOffset(), issue.getLength(), operator + "=");
}
});
}
Aggregations