use of org.eclipse.xtext.xbase.ui.refactoring.ExtractVariableRefactoring in project xtext-xtend by eclipse.
the class ExtractVariableIntegrationTest method assertAfterExtract.
protected void assertAfterExtract(final CharSequence input, final CharSequence expected, final boolean isFinal) {
try {
final String inputString = input.toString();
final String model = inputString.replace("$", "");
final IFile file = this.workbenchTestHelper.createFile("Foo", model);
final XtextEditor editor = this.workbenchTestHelper.openEditor(file);
try {
final IUnitOfWork<Change, XtextResource> _function = (XtextResource it) -> {
Change _xblockexpression = null;
{
final int offset = inputString.indexOf("$");
int _lastIndexOf = inputString.lastIndexOf("$");
int _minus = (_lastIndexOf - 1);
final int length = (_minus - offset);
final TextSelection textSelection = new TextSelection(offset, length);
final XExpression selection = this.util.findSelectedExpression(it, textSelection);
final ExtractVariableRefactoring refactoring = this.refactoringProvider.get();
refactoring.setFinal(isFinal);
refactoring.initialize(editor, selection);
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
final RefactoringStatus status = refactoring.checkAllConditions(_nullProgressMonitor);
Assert.assertTrue(status.toString(), status.isOK());
NullProgressMonitor _nullProgressMonitor_1 = new NullProgressMonitor();
Change _createChange = refactoring.createChange(_nullProgressMonitor_1);
NullProgressMonitor _nullProgressMonitor_2 = new NullProgressMonitor();
_xblockexpression = _createChange.perform(_nullProgressMonitor_2);
}
return _xblockexpression;
};
editor.getDocument().<Change>readOnly(_function);
Assert.assertEquals(expected.toString(), editor.getDocument().get());
} finally {
editor.close(false);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations