use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RefactoringHistoryService method deleteRefactoringHistory.
/**
* Deletes the refactoring history of a project. Refactorings associated
* with the workspace are not deleted.
* <p>
* If a refactoring history is deleted, all files stored in the hidden
* refactoring history folder of the project folder are removed. If no
* shared refactoring history is enabled, the refactoring history
* information is removed from the internal workspace refactoring history.
* </p>
*
* @param project
* the project to delete its history
* @param monitor
* the progress monitor to use, or <code>null</code>
* @throws CoreException
* if an error occurs while deleting the refactoring history.
* Reasons include:
* <ul>
* <li>An I/O error occurs while deleting the refactoring
* history.</li>
* </ul>
*/
public void deleteRefactoringHistory(final IProject project, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(project);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings, 100);
final String name = project.getName();
final IFileStore stateStore = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation());
if (name.equals(NAME_WORKSPACE_PROJECT)) {
final IFileStore metaStore = stateStore.getChild(NAME_HISTORY_FOLDER).getChild(name);
metaStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 100));
} else {
final URI uri = project.getLocationURI();
if (uri != null && project.isAccessible()) {
try {
final IFileStore metaStore = stateStore.getChild(NAME_HISTORY_FOLDER).getChild(name);
metaStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20));
final IFileStore projectStore = EFS.getStore(uri).getChild(NAME_HISTORY_FOLDER);
projectStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20));
} finally {
project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 60));
}
}
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class UndoableOperation2ChangeAdapter method execute.
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
ExecuteResult result = executeChange(getQuery(info, RefactoringCoreMessages.Refactoring_execute_label), monitor);
if (!result.changeExecuted) {
return createStatus(result);
}
fUndoChange = result.reverseChange;
fActiveChange = fUndoChange;
fExecuteChange = null;
return Status.OK_STATUS;
} catch (CoreException e) {
throw new ExecutionException(e.getStatus().getMessage(), e);
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RenameNonPrivateFieldTest method helper2.
private void helper2(String fieldName, String newFieldName, boolean createDelegates) throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType classA = getType(cu, "A");
IField field = classA.getField(fieldName);
boolean isEnum = JdtFlags.isEnum(field);
String id = isEnum ? IJavaRefactorings.RENAME_ENUM_CONSTANT : IJavaRefactorings.RENAME_FIELD;
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(id);
descriptor.setJavaElement(field);
descriptor.setNewName(newFieldName);
descriptor.setUpdateReferences(fUpdateReferences);
descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches);
if (!isEnum) {
descriptor.setRenameGetters(fRenameGetter);
descriptor.setRenameSetters(fRenameSetter);
descriptor.setKeepOriginal(createDelegates);
descriptor.setDeprecateDelegate(true);
}
RenameRefactoring refactoring = (RenameRefactoring) createRefactoring(descriptor);
RenameFieldProcessor processor = (RenameFieldProcessor) refactoring.getProcessor();
List elements = new ArrayList();
elements.add(field);
List args = new ArrayList();
args.add(new RenameArguments(newFieldName, fUpdateReferences));
if (fRenameGetter) {
elements.add(processor.getGetter());
args.add(new RenameArguments(processor.getNewGetterName(), fUpdateReferences));
}
if (fRenameSetter) {
elements.add(processor.getSetter());
args.add(new RenameArguments(processor.getNewSetterName(), fUpdateReferences));
}
String[] renameHandles = ParticipantTesting.createHandles(elements.toArray());
RefactoringStatus result = performRefactoring(refactoring);
assertEquals("was supposed to pass", null, result);
assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
ParticipantTesting.testRename(renameHandles, (RenameArguments[]) args.toArray(new RenameArguments[args.size()]));
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RenamePackageTest method performUndo.
private void performUndo() throws Exception {
IUndoManager um = RefactoringCore.getUndoManager();
assertTrue(um.anythingToUndo());
um.performUndo(null, new NullProgressMonitor());
assertFalse(um.anythingToUndo());
assertTrue(um.anythingToRedo());
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class Rename18Test method renameLocalVariable.
private void renameLocalVariable(String newFieldName, boolean updateReferences) throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
ISourceRange selection = getSelection(cu);
IJavaElement[] elements = cu.codeSelect(selection.getOffset(), selection.getLength());
assertEquals(1, elements.length);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_LOCAL_VARIABLE);
descriptor.setJavaElement(elements[0]);
descriptor.setNewName(newFieldName);
descriptor.setUpdateReferences(updateReferences);
descriptor.setUpdateTextualOccurrences(false);
RenameRefactoring refactoring = (RenameRefactoring) createRefactoring(descriptor);
List list = new ArrayList();
list.add(elements[0]);
List args = new ArrayList();
args.add(new RenameArguments(newFieldName, updateReferences));
String[] renameHandles = ParticipantTesting.createHandles(list.toArray());
RefactoringStatus result = performRefactoring(refactoring);
assertEquals("was supposed to pass", null, result);
assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
ParticipantTesting.testRename(renameHandles, (RenameArguments[]) args.toArray(new RenameArguments[args.size()]));
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
Aggregations