use of org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker in project che by eclipse.
the class JavaRenameProcessor method checkFinalConditions.
@Override
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
RefactoringStatus result = doCheckFinalConditions(pm, context);
if (result.hasFatalError())
return result;
IFile[] changed = getChangedFiles();
for (int i = 0; i < changed.length; i++) {
deltaFactory.change(changed[i]);
}
fRenameModifications = computeRenameModifications();
fRenameModifications.buildDelta(deltaFactory);
fRenameModifications.buildValidateEdits((ValidateEditChecker) context.getChecker(ValidateEditChecker.class));
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker in project che by eclipse.
the class DeleteResourcesProcessor method checkFinalConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
//$NON-NLS-1$
pm.beginTask("", 1);
try {
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < fResources.length; i++) {
IResource resource = fResources[i];
if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
String pathLabel = BasicElementLabels.getPathLabel(resource.getFullPath(), false);
String locationLabel = null;
IPath location = resource.getLocation();
if (location != null) {
locationLabel = BasicElementLabels.getPathLabel(location, true);
} else {
URI uri = resource.getLocationURI();
if (uri != null) {
locationLabel = BasicElementLabels.getURLPart(uri.toString());
}
}
String warning;
if (resource instanceof IFile) {
if (locationLabel != null) {
warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_file_loc, new Object[] { pathLabel, locationLabel });
} else {
warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_file, pathLabel);
}
} else {
if (locationLabel != null) {
warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_container_loc, new Object[] { pathLabel, locationLabel });
} else {
warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_container, pathLabel);
}
}
result.addWarning(warning);
}
}
checkDirtyResources(result);
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
for (int i = 0; i < fResources.length; i++) {
if (fResources[i].isPhantom()) {
result.addFatalError(Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_phantom, BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
} else if (fDeleteContents && Resources.isReadOnly(fResources[i])) {
result.addFatalError(Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_read_only, BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
} else {
deltaFactory.delete(fResources[i]);
}
}
return result;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker in project che by eclipse.
the class MoveResourcesProcessor method checkFinalConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
//$NON-NLS-1$
pm.beginTask("", 1);
try {
RefactoringStatus status = validateDestination(fDestination);
if (status.hasFatalError()) {
return status;
}
fMoveArguments = new MoveArguments(fDestination, isUpdateReferences());
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
for (int i = 0; i < fResourcesToMove.length; i++) {
IResource resource = fResourcesToMove[i];
IResource newResource = fDestination.findMember(resource.getName());
if (newResource != null) {
status.addWarning(Messages.format(RefactoringCoreMessages.MoveResourcesProcessor_warning_destination_already_exists, BasicElementLabels.getPathLabel(newResource.getFullPath(), false)));
deltaFactory.delete(newResource);
}
ResourceModifications.buildMoveDelta(deltaFactory, fResourcesToMove[i], fMoveArguments);
}
return status;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker in project che by eclipse.
the class RenameResourceProcessor method checkFinalConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
//$NON-NLS-1$
pm.beginTask("", 1);
try {
fRenameArguments = new RenameArguments(getNewResourceName(), isUpdateReferences());
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
ResourceModifications.buildMoveDelta(deltaFactory, fResource, fRenameArguments);
return new RefactoringStatus();
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker in project che by eclipse.
the class Checks method addModifiedFilesToChecker.
public static void addModifiedFilesToChecker(IFile[] filesToModify, CheckConditionsContext context) {
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
for (int i = 0; i < filesToModify.length; i++) {
deltaFactory.change(filesToModify[i]);
}
}
Aggregations