IDocument document = new Document(data.source);
ITextSelection selection = new TextSelection(document, data.sourceSelection.getOffset(),
data.sourceSelection.getLength());
IGrammarVersionProvider versionProvider = createVersionProvider();
RefactoringInfo info = new RefactoringInfo(document, selection, versionProvider);
ExtractLocalRefactoring refactoring = new ExtractLocalRefactoring(info);
ExtractLocalRequestProcessor requestProcessor = refactoring.getRequestProcessor();
requestProcessor.setVariableName("extracted_variable");
requestProcessor.setReplaceDuplicates(true);
NullProgressMonitor monitor = new NullProgressMonitor();
RefactoringStatus result = refactoring.checkAllConditions(monitor);
assertTrue("Refactoring is not ok: " + result.getMessageMatchingSeverity(RefactoringStatus.WARNING),
result.isOK());
Change change = refactoring.createChange(monitor);
change.perform(monitor);
assertContentsEqual(data.result, document.get());
FileUtilsFileBuffer.IN_TESTS = false;