@Override public Change createChange(final IProgressMonitor monitor) throws CoreException { try { final SubMonitor progress = SubMonitor.convert(monitor, RefactoringMessages.Common_CreateChanges_label, 3); final TextFileChange textFileChange = new SourceUnitChange(fSourceUnit); if (fSourceUnit.getWorkingContext() == LTK.EDITOR_CONTEXT) { textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY); } createChanges(textFileChange, progress.newChild(1)); final Map<String, String> arguments = new HashMap<String, String>(); final String description = NLS.bind( Messages.FunctionToS4Method_Descriptor_description, RRefactoringAdapter.getQuotedIdentifier(fFunctionName)); final IProject resource = fElementSet.getSingleProject(); final String project = (resource != null) ? resource.getName() : null; final String source = (project != null) ? NLS.bind(RefactoringMessages.Common_Source_Project_label, project) : RefactoringMessages.Common_Source_Workspace_label; final int flags = 0; final String comment = ""; // $NON-NLS-1$ final CommonRefactoringDescriptor descriptor = new CommonRefactoringDescriptor( getIdentifier(), project, description, comment, arguments, flags); return new RefactoringChange( descriptor, Messages.FunctionToS4Method_label, new Change[] {textFileChange}); } catch (final BadLocationException e) { throw new CoreException( new Status(IStatus.ERROR, RCore.PLUGIN_ID, "Unexpected error (concurrent change?)", e)); } finally { monitor.done(); } }