use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class InferTypeArgumentsConstraintsSolver method runSolver.
private void runSolver(SubProgressMonitor pm) {
//$NON-NLS-1$
pm.beginTask("", fWorkList.size() * 3);
while (!fWorkList.isEmpty()) {
// Get a variable whose type estimate has changed
ConstraintVariable2 cv = fWorkList.removeFirst();
List<ITypeConstraint2> usedIn = fTCModel.getUsedIn(cv);
processConstraints(usedIn);
pm.worked(1);
if (pm.isCanceled())
throw new OperationCanceledException();
}
pm.done();
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class ChangeSignatureProcessor method createChangeManager.
private TextChangeManager createChangeManager(IProgressMonitor pm, RefactoringStatus result) throws CoreException {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_preview, 2);
fChangeManager = new TextChangeManager();
boolean isNoArgConstructor = isNoArgConstructor();
Map<ICompilationUnit, Set<IType>> namedSubclassMapping = null;
if (isNoArgConstructor) {
//create only when needed;
namedSubclassMapping = createNamedSubclassMapping(new SubProgressMonitor(pm, 1));
} else {
pm.worked(1);
}
for (int i = 0; i < fOccurrences.length; i++) {
if (pm.isCanceled())
throw new OperationCanceledException();
SearchResultGroup group = fOccurrences[i];
ICompilationUnit cu = group.getCompilationUnit();
if (cu == null)
continue;
CompilationUnitRewrite cuRewrite;
if (cu.equals(getCu())) {
cuRewrite = fBaseCuRewrite;
} else {
cuRewrite = new CompilationUnitRewrite(cu);
cuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
}
ASTNode[] nodes = ASTNodeSearchUtil.findNodes(group.getSearchResults(), cuRewrite.getRoot());
//IntroduceParameterObjectRefactoring needs to update declarations first:
List<OccurrenceUpdate<? extends ASTNode>> deferredUpdates = new ArrayList<OccurrenceUpdate<? extends ASTNode>>();
for (int j = 0; j < nodes.length; j++) {
OccurrenceUpdate<? extends ASTNode> update = createOccurrenceUpdate(nodes[j], cuRewrite, result);
if (update instanceof DeclarationUpdate) {
update.updateNode();
} else {
deferredUpdates.add(update);
}
}
for (Iterator<OccurrenceUpdate<? extends ASTNode>> iter = deferredUpdates.iterator(); iter.hasNext(); ) {
iter.next().updateNode();
}
if (isNoArgConstructor && namedSubclassMapping.containsKey(cu)) {
//only non-anonymous subclasses may have noArgConstructors to modify - see bug 43444
Set<IType> subtypes = namedSubclassMapping.get(cu);
for (Iterator<IType> iter = subtypes.iterator(); iter.hasNext(); ) {
IType subtype = iter.next();
AbstractTypeDeclaration subtypeNode = ASTNodeSearchUtil.getAbstractTypeDeclarationNode(subtype, cuRewrite.getRoot());
if (subtypeNode != null)
modifyImplicitCallsToNoArgConstructor(subtypeNode, cuRewrite);
}
}
TextChange change = cuRewrite.createChange(true);
if (change != null)
fChangeManager.manage(cu, change);
}
pm.done();
return fChangeManager;
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class TextMatchUpdater method updateTextMatches.
private void updateTextMatches(IProgressMonitor pm) throws JavaModelException {
try {
IProject[] projectsInScope = getProjectsInScope();
//$NON-NLS-1$
pm.beginTask("", projectsInScope.length);
for (int i = 0; i < projectsInScope.length; i++) {
if (pm.isCanceled())
throw new OperationCanceledException();
addTextMatches(projectsInScope[i], new SubProgressMonitor(pm, 1));
}
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class ChangeSignatureProcessor method checkInitialConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.Refactoring#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException {
try {
//$NON-NLS-1$
monitor.beginTask("", 5);
RefactoringStatus result = Checks.checkIfCuBroken(fMethod);
if (result.hasFatalError())
return result;
if (fMethod == null || !fMethod.exists()) {
String message = Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_method_deleted, BasicElementLabels.getFileName(getCu()));
return RefactoringStatus.createFatalErrorStatus(message);
}
if (fMethod.getDeclaringType().isInterface()) {
fTopMethod = MethodChecks.overridesAnotherMethod(fMethod, fMethod.getDeclaringType().newSupertypeHierarchy(new SubProgressMonitor(monitor, 1)));
monitor.worked(1);
} else if (MethodChecks.isVirtual(fMethod)) {
ITypeHierarchy hierarchy = getCachedTypeHierarchy(new SubProgressMonitor(monitor, 1));
fTopMethod = MethodChecks.isDeclaredInInterface(fMethod, hierarchy, new SubProgressMonitor(monitor, 1));
if (fTopMethod == null)
fTopMethod = MethodChecks.overridesAnotherMethod(fMethod, hierarchy);
}
if (fTopMethod == null)
fTopMethod = fMethod;
if (!fTopMethod.equals(fMethod)) {
if (fTopMethod.getDeclaringType().isInterface()) {
RefactoringStatusContext context = JavaStatusContext.create(fTopMethod);
String message = Messages.format(RefactoringCoreMessages.MethodChecks_implements, new String[] { JavaElementUtil.createMethodSignature(fTopMethod), BasicElementLabels.getJavaElementName(fTopMethod.getDeclaringType().getFullyQualifiedName('.')) });
return RefactoringStatus.createStatus(RefactoringStatus.FATAL, message, context, Corext.getPluginId(), RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE, fTopMethod);
} else {
RefactoringStatusContext context = JavaStatusContext.create(fTopMethod);
String message = Messages.format(RefactoringCoreMessages.MethodChecks_overrides, new String[] { JavaElementUtil.createMethodSignature(fTopMethod), BasicElementLabels.getJavaElementName(fTopMethod.getDeclaringType().getFullyQualifiedName('.')) });
return RefactoringStatus.createStatus(RefactoringStatus.FATAL, message, context, Corext.getPluginId(), RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD, fTopMethod);
}
}
if (monitor.isCanceled())
throw new OperationCanceledException();
if (fBaseCuRewrite == null || !fBaseCuRewrite.getCu().equals(getCu())) {
fBaseCuRewrite = new CompilationUnitRewrite(getCu());
fBaseCuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
}
RefactoringStatus[] status = TypeContextChecker.checkMethodTypesSyntax(fMethod, getParameterInfos(), fReturnTypeInfo);
for (int i = 0; i < status.length; i++) {
result.merge(status[i]);
}
monitor.worked(1);
result.merge(createExceptionInfoList());
monitor.worked(1);
return result;
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class File method setContents.
@Override
public void setContents(InputStream content, int updateFlags, IProgressMonitor monitor) throws CoreException {
monitor = Policy.monitorFor(monitor);
try {
String message = NLS.bind(Messages.resources_settingContents, getFullPath());
monitor.beginTask(message, Policy.totalWork);
// if (workspace.shouldValidate)
// workspace.validateSave(this);
final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
try {
workspace.prepareOperation(rule, monitor);
ResourceInfo info = getResourceInfo(false, false);
// checkAccessible(getFlags(info));
workspace.beginOperation(true);
// IFileInfo fileInfo = getStore().fetchInfo();
internalSetContents(content, updateFlags, false, Policy.subMonitorFor(monitor, Policy.opWork));
} catch (OperationCanceledException e) {
workspace.getWorkManager().operationCanceled();
throw e;
} finally {
workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
}
} finally {
monitor.done();
FileUtil.safeClose(content);
}
}
Aggregations