use of com.python.pydev.analysis.refactoring.changes.PyCompositeChange in project Pydev by fabioz.
the class PyRenameEntryPoint method createChange.
/**
* Change is actually already created in this stage.
*/
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (this.fRequest.isModuleRenameRefactoringRequest() && this.fRequest.getSimpleResourceRename() && this.fRequest.getIFileResource() != null) {
IFile targetFile = this.fRequest.getIFileResource();
return new RenameResourceChange(targetFile.getFullPath(), fRequest.getInputName());
}
PyCompositeChange finalChange;
List<RefactoringRequest> requests = fRequest.getRequests();
if (requests.size() == 1) {
RefactoringRequest request = requests.get(0);
boolean makeUndo = !(request.isModuleRenameRefactoringRequest());
finalChange = new PyCompositeChange("RenameChange: '" + request.qualifier + "' to '" + request.inputName + "'", makeUndo);
} else {
boolean makeUndo = false;
finalChange = new PyCompositeChange("Move: " + requests.size() + " resources to '" + fRequest.getInputName() + "'", makeUndo);
}
Collections.sort(allChanges, new Comparator<Change>() {
@Override
public int compare(Change o1, Change o2) {
if (o1.getClass() != o2.getClass()) {
if (o1 instanceof PyRenameResourceChange) {
// The rename changes must be the last ones (all the text-related changes must be done already).
return 1;
}
if (o2 instanceof PyRenameResourceChange) {
return -1;
}
}
return o1.getName().compareTo(o2.getName());
}
});
finalChange.addAll(allChanges.toArray(new Change[allChanges.size()]));
return finalChange;
}
Aggregations