use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RefactoringTest method performRefactoring.
protected final RefactoringStatus performRefactoring(Refactoring ref, boolean providesUndo) throws Exception {
performDummySearch();
IUndoManager undoManager = getUndoManager();
if (DESCRIPTOR_TEST) {
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
create.run(new NullProgressMonitor());
RefactoringStatus checkingStatus = create.getConditionCheckingStatus();
if (!checkingStatus.isOK())
return checkingStatus;
Change change = create.getChange();
ChangeDescriptor descriptor = change.getDescriptor();
if (descriptor instanceof RefactoringChangeDescriptor) {
RefactoringChangeDescriptor rcd = (RefactoringChangeDescriptor) descriptor;
RefactoringDescriptor refactoringDescriptor = rcd.getRefactoringDescriptor();
if (refactoringDescriptor instanceof JavaRefactoringDescriptor) {
JavaRefactoringDescriptor jrd = (JavaRefactoringDescriptor) refactoringDescriptor;
RefactoringStatus validation = jrd.validateDescriptor();
if (!validation.isOK())
return validation;
RefactoringStatus refactoringStatus = new RefactoringStatus();
Class expected = jrd.getClass();
RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(jrd.getID());
jrd = (JavaRefactoringDescriptor) contribution.createDescriptor(jrd.getID(), jrd.getProject(), jrd.getDescription(), jrd.getComment(), contribution.retrieveArgumentMap(jrd), jrd.getFlags());
assertEquals(expected, jrd.getClass());
ref = jrd.createRefactoring(refactoringStatus);
if (!refactoringStatus.isOK())
return refactoringStatus;
TestRenameParticipantSingle.reset();
TestCreateParticipantSingle.reset();
TestMoveParticipantSingle.reset();
TestDeleteParticipantSingle.reset();
}
}
}
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
final PerformChangeOperation perform = new PerformChangeOperation(create);
perform.setUndoManager(undoManager, ref.getName());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (fIsPreDeltaTest) {
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (create.getConditionCheckingStatus().isOK() && perform.changeExecuted()) {
TestModelProvider.assertTrue(event.getDelta());
}
}
};
try {
TestModelProvider.clearDelta();
workspace.checkpoint(false);
workspace.addResourceChangeListener(listener);
executePerformOperation(perform, workspace);
} finally {
workspace.removeResourceChangeListener(listener);
}
} else {
executePerformOperation(perform, workspace);
}
RefactoringStatus status = create.getConditionCheckingStatus();
if (!status.isOK())
return status;
assertTrue("Change wasn't executed", perform.changeExecuted());
Change undo = perform.getUndoChange();
if (providesUndo) {
assertNotNull("Undo doesn't exist", undo);
assertTrue("Undo manager is empty", undoManager.anythingToUndo());
} else {
assertNull("Undo manager contains undo but shouldn't", undo);
}
return null;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class JavaDebuggerUtils method findTypeByFqn.
private List<IType> findTypeByFqn(char[][] packages, char[][] names, IJavaSearchScope scope) throws JavaModelException {
List<IType> result = new ArrayList<>();
SearchEngine searchEngine = new SearchEngine();
searchEngine.searchAllTypeNames(packages, names, scope, new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch typeNameMatch) {
result.add(typeNameMatch.getType());
}
}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
return result;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class CreateCopyOfCompilationUnitChange method getCopiedFileSource.
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException {
ICompilationUnit copy = unit.getPrimary().getWorkingCopy(null);
try {
TextChangeManager manager = createChangeManager(monitor, copy, newTypeName);
String result = manager.get(copy).getPreviewContent(new NullProgressMonitor());
return result;
} finally {
copy.discardWorkingCopy();
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class ChangeSignatureProcessor method checkCompilationofDeclaringCu.
private RefactoringStatus checkCompilationofDeclaringCu() throws CoreException {
ICompilationUnit cu = getCu();
TextChange change = fChangeManager.get(cu);
String newCuSource = change.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, cu, true, false, null);
IProblem[] problems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fBaseCuRewrite.getRoot());
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < problems.length; i++) {
IProblem problem = problems[i];
if (shouldReport(problem, newCUNode))
result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
return result;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class MultiStateTextFileChange method getCurrentDocument.
/**
* Returns a document representing the current state of the buffer,
* prior to the application of the change.
* <p>
* The returned document should not be modified.
* </p>
*
* @param monitor
* the progress monitor to use, or <code>null</code>
* @return the current document, or the empty document
* @throws CoreException
* if no document could be acquired
*/
public final IDocument getCurrentDocument(IProgressMonitor monitor) throws CoreException {
if (monitor == null)
monitor = new NullProgressMonitor();
IDocument result = null;
//$NON-NLS-1$
monitor.beginTask("", 2);
try {
result = acquireDocument(new SubProgressMonitor(monitor, 1));
} finally {
if (result != null)
releaseDocument(result, new SubProgressMonitor(monitor, 1));
}
monitor.done();
if (result == null)
result = new Document();
return result;
}
Aggregations