mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
50 lines
1.4 KiB
HTML
50 lines
1.4 KiB
HTML
<html>
|
|
<body>
|
|
Reports loops, <code>forEach</code>-like methods, and <code>ContainerUtil.process()</code> with missing cancellation checks.
|
|
<p>Runs only within the methods with <code>com.intellij.util.concurrency.annotations.RequiresReadLock</code> annotation.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code lang="kotlin">
|
|
@RequiresReadLock
|
|
fun doSomething() {
|
|
...
|
|
for (item in items) {
|
|
ProgressManager.checkCanceled() // should be present in the first line
|
|
...
|
|
}
|
|
|
|
items.forEach {
|
|
ProgressManager.checkCanceled() // should be present in the first line
|
|
...
|
|
}
|
|
...
|
|
}
|
|
</code></pre>
|
|
|
|
<p>In the case of nested loops with nothing in between:</p>
|
|
<pre><code lang="kotlin">
|
|
@RequiresReadLock
|
|
fun doSomething() {
|
|
...
|
|
for (item in items) {
|
|
// nothing in between
|
|
for (inner in item.inners) {
|
|
ProgressManager.checkCanceled() // should be present in the first line of the inner loop only
|
|
...
|
|
}
|
|
}
|
|
...
|
|
}
|
|
</code></pre>
|
|
<p>
|
|
In blocking context <code>com.intellij.openapi.progress.ProgressManager.checkCanceled()</code> should be used,
|
|
while <code>com.intellij.openapi.progress.CoroutinesKt.checkCancelled()</code> should be used in suspending one.
|
|
</p>
|
|
<p>
|
|
See <a href="https://plugins.jetbrains.com/docs/intellij/background-processes.html#cancellation">Background Processes Cancellation</a> in IntelliJ Platform Plugin SDK docs for more details.
|
|
</p>
|
|
|
|
<!-- tooltip end -->
|
|
<p><small>New in 2023.1</small>
|
|
</body>
|
|
</html>
|