Skip to content

Commit 96cd020

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 343fd57 commit 96cd020

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

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

Lines changed: 2 additions & 9 deletions
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,9 +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();
107-
}
103+
108104
RefactoringStatus result= new RefactoringStatus();
109105
mergeResourceOperationAndValidateEdit();
110106
List<IConditionChecker> values= new ArrayList<>(fCheckers.values());
@@ -120,14 +116,11 @@ public RefactoringStatus check(IProgressMonitor pm) throws CoreException {
120116
}
121117
return 0;
122118
});
119+
123120
SubMonitor sm= SubMonitor.convert(pm, "", values.size()); //$NON-NLS-1$
124121
for (IConditionChecker checker : values) {
125122
result.merge(checker.check(sm.split(1)));
126-
if (pm.isCanceled()) {
127-
throw new OperationCanceledException();
128-
}
129123
}
130-
pm.done();
131124
return result;
132125
}
133126

0 commit comments

Comments
 (0)