aboutsummaryrefslogtreecommitdiff
path: root/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-07-05 10:04:55 +0200
committerGitHub <noreply@github.com>2023-07-05 10:04:55 +0200
commit9559158bfeeb274e9ccf1b4563f1b23b42afc493 (patch)
tree3ece0887623cfe2b7148af23001867a1dd5e6597 /subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains
parentcbd9733d3dd2f52992e98e7cebd072091a572529 (diff)
downloaddokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.gz
dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.bz2
dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.zip
Decompose Kotlin/Java analysis (#3034)
* Extract analysis into separate modules
Diffstat (limited to 'subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains')
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/KotlinAnalysisPlugin.kt17
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/DocumentableSourceLanguageParser.kt16
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ExternalDocumentablesProvider.kt24
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/FullClassHierarchyBuilder.kt17
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InheritanceBuilder.kt21
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt31
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/KotlinToJavaService.kt9
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ModuleAndPackageDocumentationReader.kt15
-rw-r--r--subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/SyntheticDocumentableDetector.kt11
9 files changed, 161 insertions, 0 deletions
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/KotlinAnalysisPlugin.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/KotlinAnalysisPlugin.kt
new file mode 100644
index 00000000..3138e17b
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/KotlinAnalysisPlugin.kt
@@ -0,0 +1,17 @@
+package org.jetbrains.kotlin.analysis.kotlin
+
+import org.jetbrains.dokka.plugability.DokkaPlugin
+import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
+import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
+
+class KotlinAnalysisPlugin : DokkaPlugin() {
+
+ /*
+ * This is where stable public API will go.
+ *
+ * No stable public API for now.
+ */
+
+ @OptIn(DokkaPluginApiPreview::class)
+ override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = PluginApiPreviewAcknowledgement
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/DocumentableSourceLanguageParser.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/DocumentableSourceLanguageParser.kt
new file mode 100644
index 00000000..08a465c0
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/DocumentableSourceLanguageParser.kt
@@ -0,0 +1,16 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.model.Documentable
+import org.jetbrains.dokka.model.WithSources
+
+@InternalDokkaApi
+enum class DocumentableLanguage {
+ JAVA, KOTLIN
+}
+
+@InternalDokkaApi
+interface DocumentableSourceLanguageParser {
+ fun getLanguage(documentable: Documentable, sourceSet: DokkaConfiguration.DokkaSourceSet): DocumentableLanguage?
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ExternalDocumentablesProvider.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ExternalDocumentablesProvider.kt
new file mode 100644
index 00000000..ea418fba
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ExternalDocumentablesProvider.kt
@@ -0,0 +1,24 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.DClasslike
+
+/**
+ * Service that can be queried with [DRI] and source set to obtain a documentable for classlike.
+ *
+ * There are some cases when there is a need to process documentables of classlikes that were not defined
+ * in the project itself but are somehow related to the symbols defined in the documented project (e.g. are supertypes
+ * of classes defined in project).
+ */
+@InternalDokkaApi
+fun interface ExternalDocumentablesProvider {
+
+ /**
+ * Returns [DClasslike] matching provided [DRI] in specified source set.
+ *
+ * Result is null if compiler haven't generated matching class descriptor.
+ */
+ fun findClasslike(dri: DRI, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike?
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/FullClassHierarchyBuilder.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/FullClassHierarchyBuilder.kt
new file mode 100644
index 00000000..91460002
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/FullClassHierarchyBuilder.kt
@@ -0,0 +1,17 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.DModule
+import org.jetbrains.dokka.model.SourceSetDependent
+
+@InternalDokkaApi
+typealias Supertypes = List<DRI>
+
+@InternalDokkaApi
+typealias ClassHierarchy = SourceSetDependent<Map<DRI, Supertypes>>
+
+@InternalDokkaApi
+interface FullClassHierarchyBuilder {
+ suspend fun build(module: DModule): ClassHierarchy
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InheritanceBuilder.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InheritanceBuilder.kt
new file mode 100644
index 00000000..7f0313ea
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InheritanceBuilder.kt
@@ -0,0 +1,21 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.Documentable
+
+@InternalDokkaApi
+interface InheritanceBuilder {
+ fun build(documentables: Map<DRI, Documentable>): List<InheritanceNode>
+}
+
+@InternalDokkaApi
+data class InheritanceNode(
+ val dri: DRI,
+ val children: List<InheritanceNode> = emptyList(),
+ val interfaces: List<DRI> = emptyList(),
+ val isInterface: Boolean = false
+) {
+ override fun equals(other: Any?): Boolean = other is InheritanceNode && other.dri == dri
+ override fun hashCode(): Int = dri.hashCode()
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt
new file mode 100644
index 00000000..e2335474
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt
@@ -0,0 +1,31 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.plugability.DokkaPlugin
+import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
+import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
+
+/**
+ * A plugin for internal use, has no stable public API and thus must not be used by third party,
+ * external plugins. If you need any of the given API stabilized, please create an issue describing your use case.
+ */
+@InternalDokkaApi
+class InternalKotlinAnalysisPlugin : DokkaPlugin() {
+
+ val fullClassHierarchyBuilder by extensionPoint<FullClassHierarchyBuilder>()
+
+ val syntheticDocumentableDetector by extensionPoint<SyntheticDocumentableDetector>()
+
+ val moduleAndPackageDocumentationReader by extensionPoint<ModuleAndPackageDocumentationReader>()
+
+ val kotlinToJavaService by extensionPoint<KotlinToJavaService>()
+
+ val inheritanceBuilder by extensionPoint<InheritanceBuilder>()
+
+ val externalDocumentablesProvider by extensionPoint<ExternalDocumentablesProvider>()
+
+ val documentableSourceLanguageParser by extensionPoint<DocumentableSourceLanguageParser>()
+
+ @OptIn(DokkaPluginApiPreview::class)
+ override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = PluginApiPreviewAcknowledgement
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/KotlinToJavaService.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/KotlinToJavaService.kt
new file mode 100644
index 00000000..3631fac2
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/KotlinToJavaService.kt
@@ -0,0 +1,9 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.links.DRI
+
+@InternalDokkaApi
+interface KotlinToJavaService {
+ fun findAsJava(kotlinDri: DRI): DRI?
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ModuleAndPackageDocumentationReader.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ModuleAndPackageDocumentationReader.kt
new file mode 100644
index 00000000..6e641c3a
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/ModuleAndPackageDocumentationReader.kt
@@ -0,0 +1,15 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.model.DModule
+import org.jetbrains.dokka.model.DPackage
+import org.jetbrains.dokka.model.SourceSetDependent
+import org.jetbrains.dokka.model.doc.DocumentationNode
+
+@InternalDokkaApi
+interface ModuleAndPackageDocumentationReader {
+ fun read(module: DModule): SourceSetDependent<DocumentationNode>
+ fun read(pkg: DPackage): SourceSetDependent<DocumentationNode>
+ fun read(module: DokkaConfiguration.DokkaModuleDescription): DocumentationNode?
+}
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/SyntheticDocumentableDetector.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/SyntheticDocumentableDetector.kt
new file mode 100644
index 00000000..3dc8afa5
--- /dev/null
+++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/kotlin/analysis/kotlin/internal/SyntheticDocumentableDetector.kt
@@ -0,0 +1,11 @@
+package org.jetbrains.kotlin.analysis.kotlin.internal
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.InternalDokkaApi
+import org.jetbrains.dokka.model.Documentable
+
+// TODO [beresnev] isSynthetic could be a property of Documentable
+@InternalDokkaApi
+interface SyntheticDocumentableDetector {
+ fun isSynthetic(documentable: Documentable, sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean
+}