use of org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange in project che by eclipse.
the class RefactoringSession method prepareRenamePackageChange.
private void prepareRenamePackageChange(List<ChangeInfo> changesInfo, ChangeInfo changeInfo, Change ch) {
changeInfo.setName(ChangeInfo.ChangeName.RENAME_PACKAGE);
RenamePackageChange renameChange = (RenamePackageChange) ch;
IPath oldPackageName = new Path(renameChange.getOldName().replace('.', IPath.SEPARATOR));
IPath newPackageName = new Path(renameChange.getNewName().replace('.', IPath.SEPARATOR));
changeInfo.setOldPath(renameChange.getResourcePath().removeLastSegments(oldPackageName.segmentCount()).append(newPackageName).toString());
changeInfo.setPath(renameChange.getResourcePath().toString());
Set<IResource> compilationUnits = renameChange.getFCompilationUnitStamps().keySet();
for (IResource iResource : compilationUnits) {
ChangeInfo change = DtoFactory.newDto(ChangeInfo.class);
change.setName(ChangeInfo.ChangeName.UPDATE);
IPath fullPathOldPath = iResource.getFullPath();
IPath newPath = renameChange.getResourcePath().append(fullPathOldPath.toFile().getName());
change.setOldPath(fullPathOldPath.toString());
change.setPath(newPath.toString());
changesInfo.add(change);
}
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange in project che by eclipse.
the class RefactoringSession method prepareChangesInfo.
/**
* Prepare the information about changes which were applied.
*
* @param changes array of the applied changes
* @param changesInfo prepared list of {@link ChangeInfo}
*/
public void prepareChangesInfo(Change[] changes, List<ChangeInfo> changesInfo) {
for (Change ch : changes) {
if (ch instanceof DynamicValidationStateChange) {
prepareChangesInfo(((DynamicValidationStateChange) ch).getChildren(), changesInfo);
} else {
ChangeInfo changeInfo = DtoFactory.newDto(ChangeInfo.class);
String refactoringName = ch.getName();
if (ch instanceof UndoTextFileChange) {
changeInfo.setName(ChangeInfo.ChangeName.UPDATE);
changeInfo.setPath(((CompilationUnit) ch.getModifiedElement()).getPath().toString());
}
if (refactoringName.startsWith("Rename")) {
if (ch instanceof RenameCompilationUnitChange) {
prepareRenameCompilationUnitChange(changeInfo, ch);
} else if (ch instanceof RenamePackageChange) {
prepareRenamePackageChange(changesInfo, changeInfo, ch);
}
}
if (refactoringName.startsWith("Move")) {
prepareMoveChange(changeInfo, ch);
}
changesInfo.add(changeInfo);
}
}
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange in project che by eclipse.
the class RenamePackageProcessor method createChange.
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.RenamePackageRefactoring_creating_change, 1);
final RenameJavaElementDescriptor descriptor = createRefactoringDescriptor();
final DynamicValidationRefactoringChange result = new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenamePackageRefactoring_change_name);
result.addAll(fChangeManager.getAllChanges());
fRenamePackageChange = new RenamePackageChange(fPackage, getNewElementName(), fRenameSubpackages);
result.add(fRenamePackageChange);
monitor.worked(1);
return result;
} finally {
fChangeManager = null;
fImportsManager = null;
monitor.done();
}
}
Aggregations