Skip to content

Commit ccccbca

Browse files
committed
Use SubMonintor in CheckConditionsContext
done() call not necessary here and convert can also handle null. Also split will also check for cancellation so the additional cancellation check is not necessary. See https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
1 parent 323f82d commit ccccbca

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/CheckConditionsContext.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import org.eclipse.core.runtime.CoreException;
2323
import org.eclipse.core.runtime.IProgressMonitor;
2424
import org.eclipse.core.runtime.IStatus;
25-
import org.eclipse.core.runtime.NullProgressMonitor;
26-
import org.eclipse.core.runtime.OperationCanceledException;
2725
import org.eclipse.core.runtime.Status;
2826
import org.eclipse.core.runtime.SubMonitor;
2927

@@ -102,8 +100,7 @@ public void add(IConditionChecker checker) throws CoreException {
102100
* @throws CoreException if an error occurs during condition checking
103101
*/
104102
public RefactoringStatus check(IProgressMonitor pm) throws CoreException {
105-
if (pm == null)
106-
pm= new NullProgressMonitor();
103+
107104
RefactoringStatus result= new RefactoringStatus();
108105
mergeResourceOperationAndValidateEdit();
109106
List<IConditionChecker> values= new ArrayList<>(fCheckers.values());
@@ -117,13 +114,11 @@ public RefactoringStatus check(IProgressMonitor pm) throws CoreException {
117114
return 1;
118115
return 0;
119116
});
117+
120118
SubMonitor sm= SubMonitor.convert(pm, "", values.size()); //$NON-NLS-1$
121119
for (IConditionChecker checker : values) {
122120
result.merge(checker.check(sm.split(1)));
123-
if (pm.isCanceled())
124-
throw new OperationCanceledException();
125121
}
126-
pm.done();
127122
return result;
128123
}
129124

0 commit comments

Comments
 (0)