use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class MoveCuUpdateCreator method addUpdates.
private void addUpdates(TextChangeManager changeManager, ICompilationUnit movedUnit, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
try {
//$NON-NLS-1$
pm.beginTask("", 3);
pm.subTask(Messages.format(RefactoringCoreMessages.MoveCuUpdateCreator_searching, BasicElementLabels.getFileName(movedUnit)));
if (isInAnotherFragmentOfSamePackage(movedUnit, fDestination)) {
pm.worked(3);
return;
}
addImportToSourcePackageTypes(movedUnit, new SubProgressMonitor(pm, 1));
removeImportsToDestinationPackageTypes(movedUnit);
addReferenceUpdates(changeManager, movedUnit, new SubProgressMonitor(pm, 2), status);
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RippleMethodFinder2 method getCachedHierarchy.
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
IType rep = fUnionFind.find(type);
if (rep != null) {
Collection<IType> collection = fRootReps.get(rep);
for (Iterator<IType> iter = collection.iterator(); iter.hasNext(); ) {
IType root = iter.next();
ITypeHierarchy hierarchy = fRootHierarchies.get(root);
if (hierarchy == null) {
hierarchy = root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1));
fRootHierarchies.put(root, hierarchy);
}
if (hierarchy.contains(type))
return hierarchy;
}
}
return null;
}
use of org.eclipse.core.runtime.SubProgressMonitor 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.SubProgressMonitor in project che by eclipse.
the class ChangeSignatureProcessor 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)
*/
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
try {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_checking_preconditions, 8);
RefactoringStatus result = new RefactoringStatus();
clearManagers();
fBaseCuRewrite.clearASTAndImportRewrites();
fBaseCuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
if (isSignatureSameAsInitial())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_unchanged);
result.merge(checkSignature(true));
if (result.hasFatalError())
return result;
if (fDelegateUpdating && isSignatureClashWithInitial())
result.merge(RefactoringStatus.createErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_old_and_new_signatures_not_sufficiently_different));
String binaryRefsDescription = Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description, BasicElementLabels.getJavaElementName(getMethodName()));
ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
fRippleMethods = RippleMethodFinder2.getRelatedMethods(fMethod, binaryRefs, new SubProgressMonitor(pm, 1), null);
result.merge(checkVarargs());
if (result.hasFatalError())
return result;
fOccurrences = findOccurrences(new SubProgressMonitor(pm, 1), binaryRefs, result);
binaryRefs.addErrorIfNecessary(result);
result.merge(checkVisibilityChanges());
result.merge(checkTypeVariables());
if (!isOrderSameAsInitial())
result.merge(checkReorderings(new SubProgressMonitor(pm, 1)));
else
pm.worked(1);
if (!areNamesSameAsInitial())
result.merge(checkRenamings(new SubProgressMonitor(pm, 1)));
else
pm.worked(1);
if (result.hasFatalError())
return result;
// resolveTypesWithoutBindings(new SubProgressMonitor(pm, 1)); // already done in checkSignature(true)
createChangeManager(new SubProgressMonitor(pm, 1), result);
fCachedTypeHierarchy = null;
if (mustAnalyzeAstOfDeclaringCu())
//TODO: should also check in ripple methods (move into createChangeManager)
result.merge(checkCompilationofDeclaringCu());
if (result.hasFatalError())
return result;
Checks.addModifiedFilesToChecker(getAllFilesToModify(), context);
return result;
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor 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();
}
}
Aggregations