Java Code Examples for org.eclipse.ltk.core.refactoring.CompositeChange#add()

The following examples show how to use org.eclipse.ltk.core.refactoring.CompositeChange#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextChangeCombinerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMultipleDocumentChanges() throws Exception {
	ITextEditor editor = openInEditor(file0);
	CompositeChange compositeChange = new CompositeChange("test");
	compositeChange.add(createEditorDocumentChange(editor, 1, 1, "foo"));
	compositeChange.add(createEditorDocumentChange(editor, 2, 1, "bar"));
	CompositeChange compositeChange1 = new CompositeChange("test");
	compositeChange.add(compositeChange1);
	compositeChange1.add(createEditorDocumentChange(editor, 3, 1, "baz"));
	compositeChange1.add(createEditorDocumentChange(editor, 2, 1, "bar"));
	compositeChange1.add(createMultiEditorDocumentChange(editor, 1, 1, "foo", 4, 1, "foo"));
	Change combined = combiner.combineChanges(compositeChange);
	assertTrue(combined instanceof CompositeChange);
	assertEquals(1, ((CompositeChange) combined).getChildren().length);
	assertTrue(((CompositeChange)combined).getChildren()[0] instanceof EditorDocumentChange);
	Change undo = combined.perform(new NullProgressMonitor());
	IDocument document = getDocument(editor);
	assertEquals(MODEL.replace("1234", "foobarbazfoo"), document.get());
	undo.perform(new NullProgressMonitor());
	assertEquals(MODEL, document.get());
}
 
Example 2
Source File: DeleteChangeCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static Change createPackageFragmentRootDeleteChange(IPackageFragmentRoot root) throws JavaModelException {
	IResource resource= root.getResource();
	if (resource != null && resource.isLinked()){
		//XXX using this code is a workaround for jcore bug 31998
		//jcore cannot handle linked stuff
		//normally, we should always create DeletePackageFragmentRootChange
		CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);

		ClasspathChange change= ClasspathChange.removeEntryChange(root.getJavaProject(), root.getRawClasspathEntry());
		if (change != null) {
			composite.add(change);
		}
		Assert.isTrue(! Checks.isClasspathDelete(root));//checked in preconditions
		composite.add(createDeleteChange(resource));

		return composite;
	} else {
		Assert.isTrue(! root.isExternal());
		// TODO remove the query argument
		return new DeletePackageFragmentRootChange(root, true, null);
	}
}
 
Example 3
Source File: ChangeUtilTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testConvertSimpleCompositeChange() throws CoreException {
	IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
	ICompilationUnit cu = pack1.createCompilationUnit("E.java", "", false, null);
	CompositeChange change = new CompositeChange("simple composite change");

	RenameCompilationUnitChange resourceChange = new RenameCompilationUnitChange(cu, "ENew.java");
	change.add(resourceChange);
	CompilationUnitChange textChange = new CompilationUnitChange("insertText", cu);
	textChange.setEdit(new InsertEdit(0, "// some content"));
	change.add(textChange);

	WorkspaceEdit edit = ChangeUtil.convertToWorkspaceEdit(change);
	assertEquals(edit.getDocumentChanges().size(), 2);
	assertTrue(edit.getDocumentChanges().get(0).getRight() instanceof RenameFile);
	assertTrue(edit.getDocumentChanges().get(1).getLeft() instanceof TextDocumentEdit);
}
 
Example 4
Source File: DeleteChangeCreator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static Change createPackageFragmentRootDeleteChange(IPackageFragmentRoot root) throws JavaModelException {
	IResource resource= root.getResource();
	if (resource != null && resource.isLinked()){
		//XXX using this code is a workaround for jcore bug 31998
		//jcore cannot handle linked stuff
		//normally, we should always create DeletePackageFragmentRootChange
		CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);

		ClasspathChange change= ClasspathChange.removeEntryChange(root.getJavaProject(), root.getRawClasspathEntry());
		if (change != null) {
			composite.add(change);
		}
		Assert.isTrue(! Checks.isClasspathDelete(root));//checked in preconditions
		composite.add(createDeleteChange(resource));

		return composite;
	} else {
		Assert.isTrue(! root.isExternal());
		// TODO remove the query argument
		return new DeletePackageFragmentRootChange(root, true, null);
	}
}
 
Example 5
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Change createChange(IProgressMonitor pm) throws JavaModelException {
	IPackageFragment[] fragments= getPackages();
	pm.beginTask("", fragments.length); //$NON-NLS-1$
	CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_package);
	result.markAsSynthetic();
	IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot();
	for (int i= 0; i < fragments.length; i++) {
		if (root == null) {
			result.add(createChange(fragments[i], (IContainer)getResourceDestination()));
		} else {
			result.add(createChange(fragments[i], root));
		}
		pm.worked(1);
		if (pm.isCanceled()) {
			throw new OperationCanceledException();
		}
	}
	pm.done();
	return result;
}
 
Example 6
Source File: QualifiedNameSearchResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Change getSingleChange(IFile[] alreadyTouchedFiles) {
	Collection<TextChange> values= fChanges.values();
	if (values.size() == 0)
		return null;

	CompositeChange result= new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name);
	result.markAsSynthetic();
	List<IFile> files= Arrays.asList(alreadyTouchedFiles);
	for (Iterator<TextChange> iter= values.iterator(); iter.hasNext();) {
		TextFileChange change= (TextFileChange)iter.next();
		if (!files.contains(change.getFile())) {
			result.add(change);
		}
	}
	return result;
}
 
Example 7
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Change createChange(IProgressMonitor pm, INewNameQueries newNameQueries) throws JavaModelException {
	NewNameProposer nameProposer= new NewNameProposer();
	IPackageFragment[] fragments= getPackages();
	pm.beginTask("", fragments.length); //$NON-NLS-1$
	CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_package);
	composite.markAsSynthetic();
	IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot();
	for (int i= 0; i < fragments.length; i++) {
		if (root == null) {
			composite.add(createChange(fragments[i], (IContainer) getResourceDestination(), nameProposer, newNameQueries));
		} else {
			composite.add(createChange(fragments[i], root, nameProposer, newNameQueries));
		}
		pm.worked(1);
	}
	pm.done();
	return composite;
}
 
Example 8
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
	NewNameProposer nameProposer= new NewNameProposer();
	IPackageFragmentRoot[] roots= getPackageFragmentRoots();
	pm.beginTask("", roots.length); //$NON-NLS-1$
	CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_source_folder);
	composite.markAsSynthetic();
	IJavaProject destination= getDestinationJavaProject();
	for (int i= 0; i < roots.length; i++) {
		if (destination == null) {
			composite.add(createChange(roots[i], (IContainer) getResourceDestination(), nameProposer, copyQueries));
		} else {
			composite.add(createChange(roots[i], destination, nameProposer, copyQueries));
		}
		pm.worked(1);
	}
	pm.done();
	return composite;
}
 
Example 9
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
	NewNameProposer nameProposer= new NewNameProposer();
	IPackageFragmentRoot[] roots= getPackageFragmentRoots();
	pm.beginTask("", roots.length); //$NON-NLS-1$
	CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_source_folder);
	composite.markAsSynthetic();
	IJavaProject destination= getDestinationJavaProject();
	for (int i= 0; i < roots.length; i++) {
		if (destination == null) {
			composite.add(createChange(roots[i], (IContainer) getResourceDestination(), nameProposer, copyQueries));
		} else {
			composite.add(createChange(roots[i], destination, nameProposer, copyQueries));
		}
		pm.worked(1);
	}
	pm.done();
	return composite;
}
 
Example 10
Source File: TextChangeCombiner.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public Change combineChanges(Change masterChange) {
	if (!(masterChange instanceof CompositeChange))
		return masterChange;
	Map<Object, TextChange> resource2textChange = newLinkedHashMap();
	List<Change> otherChanges = newArrayList();
	Set<IEditorPart> editorsToSave = newHashSet();
	visitCompositeChange((CompositeChange) masterChange, resource2textChange, otherChanges, editorsToSave);
	CompositeChange compositeChange = new FilteringCompositeChange(masterChange.getName());
	for (TextChange combinedTextChange : resource2textChange.values()) {
		if(((MultiTextEdit) combinedTextChange.getEdit()).getChildrenSize() >0) {
			if(combinedTextChange instanceof EditorDocumentChange) {
				((EditorDocumentChange) combinedTextChange).setDoSave(editorsToSave.contains(((EditorDocumentChange) combinedTextChange).getEditor()));
				compositeChange.add(combinedTextChange);
			}
			else
				compositeChange.add(DisplayChangeWrapper.wrap(combinedTextChange));
		}
	}
	for(Change otherChange: otherChanges) 
		compositeChange.add(DisplayChangeWrapper.wrap(otherChange));
	if(compositeChange.getChildren().length == 0)
		return null;
	return compositeChange;
}
 
Example 11
Source File: TextChangeCombinerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMultipleFileChanges() throws Exception {
	CompositeChange compositeChange = new CompositeChange("test");
	compositeChange.add(createTextFileChange(file0, 1, 1, "foo"));
	compositeChange.add(createTextFileChange(file0, 2, 1, "bar"));
	CompositeChange compositeChange1 = new CompositeChange("test");
	compositeChange.add(compositeChange1);
	compositeChange1.add(createTextFileChange(file0, 3, 1, "baz"));
	compositeChange1.add(createTextFileChange(file0, 2, 1, "bar"));
	compositeChange1.add(createMultiTextFileChange(file0, 1, 1, "foo", 4, 1, "foo"));
	Change combined = combiner.combineChanges(compositeChange);
	assertTrue(combined instanceof CompositeChange);
	assertEquals(1, ((CompositeChange) combined).getChildren().length);
	Change combinedChild = ((CompositeChange) combined).getChildren()[0];
	assertTrue(combinedChild instanceof DisplayChangeWrapper.Wrapper);
	Change delegate = ((DisplayChangeWrapper.Wrapper) combinedChild).getDelegate();
	assertTextType(delegate);
	Change undo = combined.perform(new NullProgressMonitor());
	assertEquals(MODEL.replace("1234", "foobarbazfoo"), getContents(file0));
	undo.perform(new NullProgressMonitor());
	assertEquals(MODEL, getContents(file0));
}
 
Example 12
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
	IFile[] file= getFiles();
	IFolder[] folders= getFolders();
	ICompilationUnit[] cus= getCus();
	pm.beginTask("", cus.length + file.length + folders.length); //$NON-NLS-1$
	NewNameProposer nameProposer= new NewNameProposer();
	CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy);
	composite.markAsSynthetic();
	for (int i= 0; i < cus.length; i++) {
		composite.add(createChange(cus[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	if (pm.isCanceled()) {
		throw new OperationCanceledException();
	}
	for (int i= 0; i < file.length; i++) {
		composite.add(createChange(file[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	if (pm.isCanceled()) {
		throw new OperationCanceledException();
	}
	for (int i= 0; i < folders.length; i++) {
		composite.add(createChange(folders[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	pm.done();
	return composite;
}
 
Example 13
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
	IFile[] file= getFiles();
	IFolder[] folders= getFolders();
	ICompilationUnit[] cus= getCus();
	pm.beginTask("", cus.length + file.length + folders.length); //$NON-NLS-1$
	NewNameProposer nameProposer= new NewNameProposer();
	CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy);
	composite.markAsSynthetic();
	for (int i= 0; i < cus.length; i++) {
		composite.add(createChange(cus[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	if (pm.isCanceled())
		throw new OperationCanceledException();
	for (int i= 0; i < file.length; i++) {
		composite.add(createChange(file[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	if (pm.isCanceled())
		throw new OperationCanceledException();
	for (int i= 0; i < folders.length; i++) {
		composite.add(createChange(folders[i], nameProposer, copyQueries));
		pm.worked(1);
	}
	pm.done();
	return composite;
}
 
Example 14
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private Change createSimpleMoveChange(IProgressMonitor pm) {
	CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
	result.markAsSynthetic();
	IFile[] files= getFiles();
	IFolder[] folders= getFolders();
	ICompilationUnit[] cus= getCus();
	pm.beginTask("", files.length + folders.length + cus.length); //$NON-NLS-1$
	for (int i= 0; i < files.length; i++) {
		result.add(createChange(files[i]));
		pm.worked(1);
	}
	if (pm.isCanceled()) {
		throw new OperationCanceledException();
	}
	for (int i= 0; i < folders.length; i++) {
		result.add(createChange(folders[i]));
		pm.worked(1);
	}
	if (pm.isCanceled()) {
		throw new OperationCanceledException();
	}
	for (int i= 0; i < cus.length; i++) {
		result.add(createChange(cus[i]));
		pm.worked(1);
	}
	pm.done();
	return result;
}
 
Example 15
Source File: DeletePackageFragmentRootChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
	if (! confirmDeleteIfReferenced())
		return new NullChange();
	int resourceUpdateFlags= IResource.KEEP_HISTORY;
	int jCoreUpdateFlags= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;

	pm.beginTask("", 2); //$NON-NLS-1$
	IPackageFragmentRoot root= getRoot();
	IResource rootResource= root.getResource();
	CompositeChange result= new CompositeChange(getName());

	ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
	IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(root);
	HashMap<IFile, String> classpathFilesContents= new HashMap<IFile, String>();
	for (int i= 0; i < referencingProjects.length; i++) {
		IJavaProject javaProject= referencingProjects[i];
		IFile classpathFile= javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$
		if (classpathFile.exists()) {
			classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
		}
	}

	root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));

	rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
	for (Iterator<Entry<IFile, String>> iterator= classpathFilesContents.entrySet().iterator(); iterator.hasNext();) {
		Entry<IFile, String> entry= iterator.next();
		IFile file= entry.getKey();
		String contents= entry.getValue();
		//Restore time stamps? This should probably be some sort of UndoTextFileChange.
		TextFileChange classpathUndo= new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file);
		classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
		result.add(classpathUndo);
	}
	result.add(new UndoDeleteResourceChange(rootDescription));

	pm.done();
	return result;
}
 
Example 16
Source File: CompositeRefactoringProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	SubMonitor monitor = SubMonitor.convert(pm, processors.size());
	CompositeChange compositeChange = new CompositeChange(getProcessorName());
	for (RefactoringProcessor processor : processors) {
		if (pm.isCanceled()) {
			throw new OperationCanceledException();
		}
		compositeChange.add(processor.createChange(monitor.newChild(1)));
	}
	return textChangeCombiner.combineChanges(compositeChange);
}
 
Example 17
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws JavaModelException {
	pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$
	try {
		CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
		composite.markAsSynthetic();
		// XX workaround for bug 13558
		// <workaround>
		if (fChangeManager == null) {
			fChangeManager= createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus());
			// TODO: non-CU matches silently dropped
			RefactoringStatus status= Checks.validateModifiesFiles(getAllModifiedFiles(), null);
			if (status.hasFatalError())
				fChangeManager= new TextChangeManager();
		}
		// </workaround>

		composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements, fChangeManager.getAllChanges()));

		Change fileMove= createSimpleMoveChange(new SubProgressMonitor(pm, 1));
		if (fileMove instanceof CompositeChange) {
			composite.merge(((CompositeChange) fileMove));
		} else {
			composite.add(fileMove);
		}
		return composite;
	} finally {
		pm.done();
	}
}
 
Example 18
Source File: CompositeChangeProcessor.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Change createChange() throws MisconfigurationException {
    CompositeChange change = new CompositeChange(name);
    for (IChangeProcessor processor : processors) {
        change.add(processor.createChange());
    }

    return change;
}
 
Example 19
Source File: ReorgCorrectionsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void getWrongPackageDeclNameProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
	ICompilationUnit cu= context.getCompilationUnit();
	boolean isLinked= cu.getResource().isLinked();

	// correct package declaration
	int relevance= cu.getPackageDeclarations().length == 0 ? IProposalRelevance.MISSING_PACKAGE_DECLARATION : IProposalRelevance.CORRECT_PACKAGE_DECLARATION; // bug 38357
	proposals.add(new CorrectPackageDeclarationProposal(cu, problem, relevance));

	// move to package
	IPackageDeclaration[] packDecls= cu.getPackageDeclarations();
	String newPackName= packDecls.length > 0 ? packDecls[0].getElementName() : ""; //$NON-NLS-1$

	IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(cu);
	IPackageFragment newPack= root.getPackageFragment(newPackName);

	ICompilationUnit newCU= newPack.getCompilationUnit(cu.getElementName());
	if (!newCU.exists() && !isLinked) {
		String label;
		if (newPack.isDefaultPackage()) {
			label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_default_description, BasicElementLabels.getFileName(cu));
		} else {
			String packageLabel= JavaElementLabels.getElementLabel(newPack, JavaElementLabels.ALL_DEFAULT);
			label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_description, new Object[] { BasicElementLabels.getFileName(cu), packageLabel });
		}
		CompositeChange composite= new CompositeChange(label);
		composite.add(new CreatePackageChange(newPack));
		composite.add(new MoveCompilationUnitChange(cu, newPack));

		proposals.add(new ChangeCorrectionProposal(label, composite, IProposalRelevance.MOVE_CU_TO_PACKAGE, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_MOVE)));
	}
}
 
Example 20
Source File: DeletePackageFragmentRootChange.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
	if (! confirmDeleteIfReferenced()) {
		return new NullChange();
	}
	int resourceUpdateFlags= IResource.KEEP_HISTORY;
	int jCoreUpdateFlags= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;

	pm.beginTask("", 2); //$NON-NLS-1$
	IPackageFragmentRoot root= getRoot();
	IResource rootResource= root.getResource();
	CompositeChange result= new CompositeChange(getName());

	IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(root);
	HashMap<IFile, String> classpathFilesContents= new HashMap<>();
	for (int i= 0; i < referencingProjects.length; i++) {
		IJavaProject javaProject= referencingProjects[i];
		IFile classpathFile= javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$
		if (classpathFile.exists()) {
			classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
		}
	}

	root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));

	//		TODO can't port org.eclipse.ui.ide.undo.ResourceDescription.class
	//		ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
	//		rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
	for (Iterator<Entry<IFile, String>> iterator= classpathFilesContents.entrySet().iterator(); iterator.hasNext();) {
		Entry<IFile, String> entry= iterator.next();
		IFile file= entry.getKey();
		String contents= entry.getValue();
		//Restore time stamps? This should probably be some sort of UndoTextFileChange.
		TextFileChange classpathUndo= new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file);
		classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
		result.add(classpathUndo);
	}
	//		result.add(new UndoDeleteResourceChange(rootDescription));

	pm.done();
	return result;
}