Skip to content

Commit 897be0e

Browse files
authored
Update Analysis API to 2.1.20-dev-4370 (#3802)
1 parent 659f955 commit 897be0e

File tree

7 files changed

+39
-11
lines changed

7 files changed

+39
-11
lines changed

dokka-integration-tests/gradle/src/testTemplateProjectTasksExecutionStress/kotlin/SequentialTasksExecutionStressTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class SequentialTasksExecutionStressTest : AbstractGradleIntegrationTest() {
2525
buildVersions,
2626
"runTasks",
2727
"-Ptask_number=$iterations",
28-
jvmArgs = listOf("-Xmx1G", "-XX:MaxMetaspaceSize=500m"),
28+
jvmArgs = listOf(
29+
"-Xmx1G", "-XX:MaxMetaspaceSize=500m",
30+
"-XX:SoftRefLRUPolicyMSPerMB=10" // to free up the metaspace on JVM 8, see https://youtrack.jetbrains.com/issue/KT-55831/
31+
),
2932
enableBuildCache = false,
3033
).buildRelaxed()
3134

dokka-subprojects/analysis-java-psi/api/analysis-java-psi.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public final class org/jetbrains/dokka/analysis/java/ExceptionJavadocTag$Compani
2626

2727
public final class org/jetbrains/dokka/analysis/java/JavaAnalysisPlugin : org/jetbrains/dokka/plugability/DokkaPlugin {
2828
public fun <init> ()V
29+
public final fun disposeGlobalStandaloneApplicationServices ()V
2930
public final fun getDocCommentCreators ()Lorg/jetbrains/dokka/plugability/ExtensionPoint;
3031
public final fun getDocCommentFinder ()Lorg/jetbrains/dokka/analysis/java/doccomment/DocCommentFinder;
3132
public final fun getDocCommentParsers ()Lorg/jetbrains/dokka/plugability/ExtensionPoint;

dokka-subprojects/analysis-java-psi/src/main/kotlin/org/jetbrains/dokka/analysis/java/JavaAnalysisPlugin.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ public class JavaAnalysisPlugin : DokkaPlugin() {
7171
DocCommentFinder(logger, docCommentFactory)
7272
}
7373

74+
// TODO #3936(https://youtrack.jetbrains.com/issue/KT-71862) use an endpoint from AA
75+
/**
76+
* Disposes global resources which would persist after unloading Analysis API (Symbols analysis) and IJ platform classes.
77+
*
78+
* **Important:** Once this function has been called, Analysis API *and* IntelliJ platform classes should not be used anymore. The classes
79+
* should either be unloaded or the whole program should be shut down.
80+
*
81+
* Note: Disposing of resources, including threads, allows unloading Dokka's class loader.
82+
*/
83+
@InternalDokkaApi
84+
public fun disposeGlobalStandaloneApplicationServices() {
85+
@Suppress("UnstableApiUsage")
86+
com.intellij.util.concurrency.AppExecutorUtil.shutdownApplicationScheduledExecutorService()
87+
}
88+
7489
internal val javaDocCommentCreator by extending {
7590
docCommentCreators providing { JavaDocCommentCreator() }
7691
}

dokka-subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/configuration/TestDokkaConfigurationMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fun TestDokkaConfiguration.toDokkaConfiguration(projectDir: File): DokkaConfigur
8282
override val suppressInheritedMembers: Boolean
8383
get() = throw NotImplementedError("Not expected to be used by analysis modules")
8484
override val finalizeCoroutines: Boolean
85-
get() = throw NotImplementedError("Not expected to be used by analysis modules")
85+
get() = false
8686
}
8787
}
8888

dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ import org.jetbrains.dokka.analysis.kotlin.symbols.services.*
2020
import org.jetbrains.dokka.analysis.kotlin.symbols.services.KotlinDocumentableSourceLanguageParser
2121
import org.jetbrains.dokka.analysis.kotlin.symbols.services.SymbolExternalDocumentablesProvider
2222
import org.jetbrains.dokka.analysis.kotlin.symbols.translators.DefaultSymbolToDocumentableTranslator
23-
import org.jetbrains.dokka.plugability.DokkaPlugin
24-
import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
25-
import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
26-
import org.jetbrains.dokka.plugability.querySingle
23+
import org.jetbrains.dokka.plugability.*
2724
import org.jetbrains.dokka.renderers.PostAction
2825
import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation
2926

@@ -42,7 +39,14 @@ public class SymbolsAnalysisPlugin : DokkaPlugin() {
4239
}
4340

4441
internal val disposeKotlinAnalysisPostAction by extending {
45-
CoreExtensions.postActions with PostAction { querySingle { kotlinAnalysis }.close() }
42+
CoreExtensions.postActions providing { context ->
43+
PostAction {
44+
querySingle { kotlinAnalysis }.close()
45+
if (context.configuration.finalizeCoroutines)
46+
// TODO #3936(https://youtrack.jetbrains.com/issue/KT-71862) use an endpoint from AA
47+
javaAnalysisPlugin.disposeGlobalStandaloneApplicationServices()
48+
}
49+
}
4650
}
4751

4852
internal val symbolToDocumentableTranslator by extending {

dokka-subprojects/core/src/main/kotlin/org/jetbrains/dokka/configuration.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,22 @@ public interface DokkaConfiguration : Serializable {
147147
/**
148148
* Whether coroutines dispatchers should be shutdown after
149149
* generating documentation via [DokkaGenerator.generate].
150+
* Additionally, whether the Analysis API and IJ platform global
151+
* services should be shutdown.
150152
*
151-
* It effectively stops all background threads associated with
153+
* If this is enabled, Coroutines *and* the Analysis API *and* IntelliJ
154+
* platform classes should no longer be used after the documentation is generated once.
155+
*
156+
* For example, it effectively stops all background threads associated with
152157
* coroutines in order to make classes unloadable by the JVM,
153158
* and rejects all new tasks with [RejectedExecutionException]
154159
*
155-
* This is primarily useful for multi-module builds where coroutines
160+
* This is primarily useful for multi-module builds where global services
156161
* can be shut down after each module's partial task to avoid
157162
* possible memory leaks.
158163
*
159164
* However, this can lead to problems in specific lifecycles where
160-
* coroutines are shared and will be reused after documentation generation,
165+
* global services are shared and will be reused after documentation generation,
161166
* and closing it down will leave the build in an inoperable state.
162167
* One such example is unit tests, for which finalization should be disabled.
163168
*/

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ javaDiffUtils = "4.12"
1616

1717
## Analysis
1818
kotlin-compiler = "2.0.20"
19-
kotlin-compiler-k2 = "2.1.0-dev-5441"
19+
kotlin-compiler-k2 = "2.1.20-dev-4370"
2020

2121
# MUST match the version of the intellij platform used in the kotlin compiler,
2222
# otherwise this will lead to different versions of psi API and implementations

0 commit comments

Comments
 (0)