mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
- Added support for forEach() and similar methods, and ContainerUtil.process() GitOrigin-RevId: fc9b66f3584cf94d603d9a84825f4142de92544d
37 lines
1.3 KiB
Java
37 lines
1.3 KiB
Java
package inspections.cancellationCheckInLoops;
|
|
|
|
import com.intellij.util.concurrency.annotations.RequiresReadLock;
|
|
import com.intellij.util.containers.ContainerUtil;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Stream;
|
|
|
|
import static inspections.cancellationCheckInLoops.Foo.doSomething;
|
|
|
|
class Clazz {
|
|
|
|
@RequiresReadLock
|
|
public static void foo(Iterable<String> iterable, Iterator<String> iterator, List<String> list) {
|
|
ContainerUtil.process(list, a -> {
|
|
iterable.<warning descr="Cancellation check 'com.intellij.openapi.progress.ProgressManager.checkCanceled' should be the first statement in a loop body">forEach</warning>(b -> {
|
|
doSomething();
|
|
});
|
|
return true;
|
|
});
|
|
|
|
for (String a : iterable) {
|
|
iterator.<warning descr="Cancellation check 'com.intellij.openapi.progress.ProgressManager.checkCanceled' should be the first statement in a loop body">forEachRemaining</warning>(b -> {
|
|
doSomething();
|
|
});
|
|
}
|
|
|
|
iterable.forEach(a -> {
|
|
<warning descr="Cancellation check 'com.intellij.openapi.progress.ProgressManager.checkCanceled' should be the first statement in a loop body">for</warning> (String b : iterable) {
|
|
doSomething();
|
|
}
|
|
});
|
|
}
|
|
}
|