execution_contexts.topic: Include elements via <snippet>

This commit is contained in:
Karol Lewandowski 2025-02-20 15:15:20 +01:00 committed by Karol Lewandowski
parent 981a8ff911
commit e81a2ee7d1

View File

@ -5,7 +5,7 @@
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd" xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
id="execution_contexts" title="Execution Contexts"> id="execution_contexts" title="Execution Contexts">
<var name="id_postfix"></var><title>Execution Contexts</title> <title>Execution Contexts</title>
<link-summary>Tracking execution progress, checking for cancellations, and switching between different execution contexts.</link-summary> <link-summary>Tracking execution progress, checking for cancellations, and switching between different execution contexts.</link-summary>
<p>The IntelliJ Platform provides APIs that allow tracking the progress of background processes and canceling their <p>The IntelliJ Platform provides APIs that allow tracking the progress of background processes and canceling their
@ -25,14 +25,19 @@
<li><a anchor="progress-indicator"/> — obsolete since 2024.1</li> <li><a anchor="progress-indicator"/> — obsolete since 2024.1</li>
</list> </list>
<p id="progress-indicator-migration-note%id_postfix%">Currently, the Progress Indicator context is the most widely used approach in the IntelliJ Platform. <snippet id="progress-indicator-migration-note">
As the platform's execution model moves towards <a href="launching_coroutines.md">coroutines</a>, this approach <p>Currently, the Progress Indicator context is the most widely used approach in the IntelliJ Platform.
can be considered obsolete.</p> As the platform's execution model moves towards <a href="launching_coroutines.md">coroutines</a>, this approach
can be considered obsolete.</p>
</snippet>
<p>Starting with 2024.2, it is recommended to execute new code in the <a anchor="coroutine-execution-context-coroutines"/>.</p> <p>Starting with 2024.2, it is recommended to execute new code in the <a anchor="coroutine-execution-context-coroutines"/>.</p>
<p id="sections-note%id_postfix%">The following sections explain the contexts and provide information about process cancellation, progress <snippet id="sections-note">
tracking, and switching between contexts.</p> <p>The following sections explain the contexts and provide information about process cancellation, progress
tracking, and switching between contexts.</p>
</snippet>
<chapter title="Coroutine Execution Context" id="coroutine-execution-context-coroutines"><!--FIXME: id--> <chapter title="Coroutine Execution Context" id="coroutine-execution-context-coroutines"><!--FIXME: id-->
<primary-label ref="2024.2"/> <primary-label ref="2024.2"/>
@ -72,16 +77,12 @@
<li><a anchor="blocking-context"/></li> <li><a anchor="blocking-context"/></li>
<li><a anchor="progress-indicator"/> — obsolete since 2024.1</li> <li><a anchor="progress-indicator"/> — obsolete since 2024.1</li>
</list> </list>
<include from="execution_contexts.topic" element-id="progress-indicator-migration-note"> <include from="execution_contexts.topic" element-id="progress-indicator-migration-note"/>
<var name="id_postfix" value="-8d50ec"/>
</include>
<p>Starting with 2024.1, it is recommended to execute new code in the <p>Starting with 2024.1, it is recommended to execute new code in the
<a anchor="suspending-context-coroutines">Suspending Context</a>.</p> <a anchor="suspending-context-coroutines">Suspending Context</a>.</p>
<include from="execution_contexts.topic" element-id="sections-note"> <include from="execution_contexts.topic" element-id="sections-note"/>
<var name="id_postfix" value="-8d50ee"/>
</include>
<chapter title="Suspending Context (Coroutines)" id="suspending-context-coroutines"> <chapter title="Suspending Context (Coroutines)" id="suspending-context-coroutines">
<primary-label ref="2024.1"/> <primary-label ref="2024.1"/>
@ -128,7 +129,6 @@
</tab> </tab>
</tabs> </tabs>
<chapter title="Progress Indicator" id="progress-indicator"> <chapter title="Progress Indicator" id="progress-indicator">
<primary-label ref="obsolete-2024.1"/> <primary-label ref="obsolete-2024.1"/>
<p>Code executed via the Progress API <p>Code executed via the Progress API
@ -145,6 +145,7 @@
performant solution.</p> performant solution.</p>
</tip> </tip>
</chapter> </chapter>
<chapter title="Execution Contexts APIs" id="execution-contexts-apis"> <chapter title="Execution Contexts APIs" id="execution-contexts-apis">
<chapter title="Cancellation Check" id="cancellation-check"> <chapter title="Cancellation Check" id="cancellation-check">
<p>The following table presents APIs to use for checking whether a task was canceled in different execution <p>The following table presents APIs to use for checking whether a task was canceled in different execution
@ -169,17 +170,19 @@
</list> </list>
</td> </td>
</tr> </tr>
<tr id="cancellation-check-progress-indicator-row%id_postfix%"> <snippet id="cancellation-check-progress-indicator-row">
<td>Progress&nbsp;Indicator</td> <tr>
<td> <td>Progress&nbsp;Indicator</td>
<list> <td>
<li><a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicator.java"> <list>
<code>ProgressIndicator.checkCanceled()</code></a></li> <li><a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicator.java">
<li><a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java"> <code>ProgressIndicator.checkCanceled()</code></a></li>
<code>ProgressManager.checkCanceled()</code></a></li> <li><a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java">
</list> <code>ProgressManager.checkCanceled()</code></a></li>
</td> </list>
</tr> </td>
</tr>
</snippet>
</table> </table>
</tab> </tab>
<tab title="2024.1" group-key="2024.1"> <tab title="2024.1" group-key="2024.1">
@ -210,9 +213,7 @@
</list> </list>
</td> </td>
</tr> </tr>
<include from="execution_contexts.topic" element-id="cancellation-check-progress-indicator-row"> <include from="execution_contexts.topic" element-id="cancellation-check-progress-indicator-row"/>
<var name="id_postfix" value="-8d50f1"/>
</include>
</table> </table>
</tab> </tab>
</tabs> </tabs>
@ -227,58 +228,60 @@
<table style="header-column"> <table style="header-column">
<tr> <tr>
<td width="17%">Coroutine Execution Context</td> <td width="17%">Coroutine Execution Context</td>
<td id="progress-reporting-coroutine-execution-context-cell%id_postfix%"> <snippet id="progress-reporting-coroutine-execution-context-cell">
<list> <td>
<li><a href="%gh-ic%/platform/util/progress/src/impl/ProgressStep.kt"><code>ProgressStep</code></a> <list>
- a step-based progress reporting (see its KDoc for details) <li><a href="%gh-ic%/platform/util/progress/src/impl/ProgressStep.kt"><code>ProgressStep</code></a>
</li> - a step-based progress reporting (see its KDoc for details)
<li><a href="%gh-ic%/platform/util/progress/src/RawProgressReporter.kt"><code>RawProgressReporter</code></a> </li>
- a raw text, details, and fraction reporting (invoked via <a <li><a href="%gh-ic%/platform/util/progress/src/RawProgressReporter.kt"><code>RawProgressReporter</code></a>
href="%gh-ic%/platform/util/progress/src/steps.kt"><code>reportRawProgress()</code></a>) - a raw text, details, and fraction reporting (invoked via <a
</li> href="%gh-ic%/platform/util/progress/src/steps.kt"><code>reportRawProgress()</code></a>)
</list> </li>
<p> </list>
Any <a href="%gh-ic%/platform/util/progress/src/steps.kt"><code>report*Progress()</code></a> <p>
function must be used inside <code>withBackgroundProgress()</code>, <code>withModalProgress()</code>, Any <a href="%gh-ic%/platform/util/progress/src/steps.kt"><code>report*Progress()</code></a>
or <code>runWithModalProgressBlocking()</code> from <a function must be used inside <code>withBackgroundProgress()</code>, <code>withModalProgress()</code>,
href="%gh-ic%/platform/progress/shared/src/tasks.kt"> or <code>runWithModalProgressBlocking()</code> from <a
<path>tasks.kt</path> href="%gh-ic%/platform/progress/shared/src/tasks.kt">
</a>. <path>tasks.kt</path>
Otherwise, if there is no reporter in the context, using <code>report*Progress()</code> will </a>.
have no effect. Otherwise, if there is no reporter in the context, using <code>report*Progress()</code> will
Example: have no effect.
</p> Example:
<code-block lang="kotlin"> </p>
withBackgroundProgress(...) { // or other <code-block lang="kotlin">
// ... withBackgroundProgress(...) { // or other
reportProgress { reporter -> // or another report*Progress // ...
// do tasks and report progress reportProgress { reporter -> // or another report*Progress
// do tasks and report progress
}
// ...
} }
// ... </code-block>
} </td>
</code-block> </snippet>
</td>
</tr>
<tr id="progress-reporting-progress-indicator-row%id_postfix%">
<td>Progress&nbsp;Indicator</td>
<td>
<a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicator.java"><code>ProgressIndicator</code>'s</a>
or <a
href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java"><code>ProgressManager</code>'s</a>
methods
<p>See <a href="background_processes.md#tracking-progress">Background Processes: Tracking
Progress</a> for details.</p>
</td>
</tr> </tr>
<snippet id="progress-reporting-progress-indicator-row">
<tr>
<td>Progress&nbsp;Indicator</td>
<td>
<a href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicator.java"><code>ProgressIndicator</code>'s</a>
or <a
href="%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java"><code>ProgressManager</code>'s</a>
methods
<p>See <a href="background_processes.md#tracking-progress">Background Processes: Tracking
Progress</a> for details.</p>
</td>
</tr>
</snippet>
</table> </table>
</tab> </tab>
<tab title="2024.1" group-key="2024.1"> <tab title="2024.1" group-key="2024.1">
<table style="header-column"> <table style="header-column">
<tr> <tr>
<td width="17%">Suspending Context</td> <td width="17%">Suspending Context</td>
<include from="execution_contexts.topic" element-id="progress-reporting-coroutine-execution-context-cell"> <include from="execution_contexts.topic" element-id="progress-reporting-coroutine-execution-context-cell"/>
<var name="id_postfix" value="-8d50f5"/>
</include>
</tr> </tr>
<tr> <tr>
<td>Blocking Context</td> <td>Blocking Context</td>
@ -286,9 +289,7 @@
unavailable unavailable
</td> </td>
</tr> </tr>
<include from="execution_contexts.topic" element-id="progress-reporting-progress-indicator-row"> <include from="execution_contexts.topic" element-id="progress-reporting-progress-indicator-row"/>
<var name="id_postfix" value="-8d50f7"/>
</include>
</table> </table>
</tab> </tab>
</tabs> </tabs>