aboutsummaryrefslogtreecommitdiff
path: root/subprojects/analysis-kotlin-symbols/src/main/kotlin/org
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-10-11 20:00:09 +0300
committerGitHub <noreply@github.com>2023-10-11 20:00:09 +0300
commitedd51958c657e0aa226a584b6c7b8d0749641b9f (patch)
treeae0004ad3d86a0534c25e153c61f274697e0ecec /subprojects/analysis-kotlin-symbols/src/main/kotlin/org
parent562a5951ca942c0bd26d839f2ebf509b43ca3c59 (diff)
downloaddokka-edd51958c657e0aa226a584b6c7b8d0749641b9f.tar.gz
dokka-edd51958c657e0aa226a584b6c7b8d0749641b9f.tar.bz2
dokka-edd51958c657e0aa226a584b6c7b8d0749641b9f.zip
Avoid calling analyze on built-ins (#3200)
Otherwise, `Caused by: org.jetbrains.kotlin.utils.exceptions.KotlinIllegalArgumentExceptionWithAttachments: Unexpected class org.jetbrains.kotlin.analysis.project.structure.KtBuiltinsModule at org.jetbrains.kotlin.analysis.low.level.api.fir.util.ExceptionUtilsKt.errorWithFirSpecificEntries(exceptionUtils.kt:50)`
Diffstat (limited to 'subprojects/analysis-kotlin-symbols/src/main/kotlin/org')
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt2
-rw-r--r--subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt14
2 files changed, 11 insertions, 5 deletions
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt
index 43435a55..ef795145 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt
@@ -93,7 +93,7 @@ public class SymbolsAnalysisPlugin : DokkaPlugin() {
plugin<InternalKotlinAnalysisPlugin>().documentableSourceLanguageParser providing { KotlinDocumentableSourceLanguageParser() }
}
internal val symbolFullClassHierarchyBuilder by extending {
- plugin<InternalKotlinAnalysisPlugin>().fullClassHierarchyBuilder providing { SymbolFullClassHierarchyBuilder() }
+ plugin<InternalKotlinAnalysisPlugin>().fullClassHierarchyBuilder providing ::SymbolFullClassHierarchyBuilder
}
internal val symbolSyntheticDocumentableDetector by extending {
diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt
index 375aee90..0e90bec8 100644
--- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt
+++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolFullClassHierarchyBuilder.kt
@@ -16,12 +16,18 @@ import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.dokka.analysis.kotlin.internal.ClassHierarchy
import org.jetbrains.dokka.analysis.kotlin.internal.FullClassHierarchyBuilder
import org.jetbrains.dokka.analysis.kotlin.internal.Supertypes
+import org.jetbrains.dokka.analysis.kotlin.symbols.plugin.SymbolsAnalysisPlugin
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.kotlin.psi.KtClassOrObject
import java.util.concurrent.ConcurrentHashMap
-internal class SymbolFullClassHierarchyBuilder : FullClassHierarchyBuilder {
- override suspend fun build(module: DModule): ClassHierarchy {
+internal class SymbolFullClassHierarchyBuilder(val context: DokkaContext) : FullClassHierarchyBuilder {
+ private val kotlinAnalysis = context.plugin<SymbolsAnalysisPlugin>().querySingle { kotlinAnalysis }
+
+ override suspend fun build(module: DModule): ClassHierarchy {
val map = module.sourceSets.associateWith { ConcurrentHashMap<DRI, List<DRI>>() }
module.packages.forEach { visitDocumentable(it, map) }
return map
@@ -41,7 +47,7 @@ internal class SymbolFullClassHierarchyBuilder : FullClassHierarchyBuilder {
if (supersMap[dri] == null) {
supersMap[dri] = supertypesDriWithKType.map { it.first }
- supertypesDriWithKType.forEach{ collectSupertypesFromKtType(it, supersMap) }
+ supertypesDriWithKType.forEach { collectSupertypesFromKtType(it, supersMap) }
}
}
@@ -73,7 +79,7 @@ internal class SymbolFullClassHierarchyBuilder : FullClassHierarchyBuilder {
documentable.sources.forEach { (sourceSet, source) ->
if (source is KtPsiDocumentableSource) {
(source.psi as? KtClassOrObject)?.let { psi ->
- analyze(psi) {
+ analyze(kotlinAnalysis[sourceSet].mainModule) {
val type = psi.getNamedClassOrObjectSymbol()?.buildSelfClassType() ?: return@analyze
hierarchy[sourceSet]?.let { collectSupertypesFromKtType(documentable.dri to type, it) }
}