From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- .../descriptors/compiler/AnalysisContextCreator.kt | 4 ++-- .../compiler/CompilerDescriptorAnalysisPlugin.kt | 26 ++++++++++++++-------- .../compiler/CompilerExtensionPointProvider.kt | 10 ++++----- .../descriptors/compiler/DescriptorFinder.kt | 4 ++-- .../kotlin/descriptors/compiler/KDocFinder.kt | 8 +++---- .../kotlin/descriptors/compiler/KLibService.kt | 6 ++--- .../descriptors/compiler/MockApplicationHack.kt | 4 ++-- .../compiler/configuration/AnalysisContext.kt | 12 +++++----- .../compiler/configuration/AnalysisEnvironment.kt | 2 +- .../compiler/configuration/KotlinAnalysis.kt | 10 ++++----- .../compiler/impl/KotlinSampleProvider.kt | 8 +++++-- .../descriptors/ide/CoreKotlinCacheService.kt | 4 ++-- .../descriptors/ide/IdeDescriptorAnalysisPlugin.kt | 2 +- 13 files changed, 57 insertions(+), 43 deletions(-) (limited to 'subprojects/analysis-kotlin-descriptors') diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/AnalysisContextCreator.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/AnalysisContextCreator.kt index 13c7d30d..67476a50 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/AnalysisContextCreator.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/AnalysisContextCreator.kt @@ -13,8 +13,8 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.descriptors.ModuleDescriptor @InternalDokkaApi -interface AnalysisContextCreator { - fun create( +public interface AnalysisContextCreator { + public fun create( project: MockProject, moduleDescriptor: ModuleDescriptor, moduleResolver: ResolverForModule, diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt index ff9da869..c59a43b2 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt @@ -20,26 +20,34 @@ import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.translator.Defau import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.translator.DefaultExternalDocumentablesProvider import org.jetbrains.dokka.renderers.PostAction import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin +import org.jetbrains.dokka.analysis.kotlin.internal.SampleProviderFactory import org.jetbrains.dokka.plugability.* import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation @Suppress("unused") @InternalDokkaApi -class CompilerDescriptorAnalysisPlugin : DokkaPlugin() { +public class CompilerDescriptorAnalysisPlugin : DokkaPlugin() { - val kdocFinder by extensionPoint() + @InternalDokkaApi + public val kdocFinder: ExtensionPoint by extensionPoint() - val descriptorFinder by extensionPoint() + @InternalDokkaApi + public val descriptorFinder: ExtensionPoint by extensionPoint() - val klibService by extensionPoint() + @InternalDokkaApi + public val klibService: ExtensionPoint by extensionPoint() - val compilerExtensionPointProvider by extensionPoint() + @InternalDokkaApi + public val compilerExtensionPointProvider: ExtensionPoint by extensionPoint() - val mockApplicationHack by extensionPoint() + @InternalDokkaApi + public val mockApplicationHack: ExtensionPoint by extensionPoint() - val analysisContextCreator by extensionPoint() + @InternalDokkaApi + public val analysisContextCreator: ExtensionPoint by extensionPoint() - val kotlinAnalysis by extensionPoint() + @InternalDokkaApi + public val kotlinAnalysis: ExtensionPoint by extensionPoint() internal val documentableAnalyzerImpl by extending { plugin().documentableSourceLanguageParser providing { CompilerDocumentableSourceLanguageParser() } @@ -72,7 +80,7 @@ class CompilerDescriptorAnalysisPlugin : DokkaPlugin() { * So it should have a possibility to override this extension */ @InternalDokkaApi - val kotlinSampleProviderFactory by extending { + public val kotlinSampleProviderFactory: Extension by extending { plugin().sampleProviderFactory providing ::KotlinSampleProviderFactory } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerExtensionPointProvider.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerExtensionPointProvider.kt index dace8dc1..e42efe41 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerExtensionPointProvider.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerExtensionPointProvider.kt @@ -8,11 +8,11 @@ import org.jetbrains.dokka.InternalDokkaApi import org.jetbrains.kotlin.extensions.ApplicationExtensionDescriptor @InternalDokkaApi -interface CompilerExtensionPointProvider { - fun get(): List +public interface CompilerExtensionPointProvider { + public fun get(): List - class CompilerExtensionPoint( - val extensionDescriptor: ApplicationExtensionDescriptor, - val extensions: List + public class CompilerExtensionPoint( + public val extensionDescriptor: ApplicationExtensionDescriptor, + public val extensions: List ) } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/DescriptorFinder.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/DescriptorFinder.kt index f7224157..db06647d 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/DescriptorFinder.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/DescriptorFinder.kt @@ -9,6 +9,6 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.psi.KtDeclaration @InternalDokkaApi -interface DescriptorFinder { - fun KtDeclaration.findDescriptor(): DeclarationDescriptor? +public interface DescriptorFinder { + public fun KtDeclaration.findDescriptor(): DeclarationDescriptor? } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KDocFinder.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KDocFinder.kt index f2bcba90..e5367211 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KDocFinder.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KDocFinder.kt @@ -14,10 +14,10 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils @InternalDokkaApi -interface KDocFinder { - fun KtElement.findKDoc(): KDocTag? +public interface KDocFinder { + public fun KtElement.findKDoc(): KDocTag? - fun DeclarationDescriptor.find( + public fun DeclarationDescriptor.find( descriptorToPsi: (DeclarationDescriptorWithSource) -> PsiElement? = { DescriptorToSourceUtils.descriptorToDeclaration( it @@ -25,7 +25,7 @@ interface KDocFinder { } ): KDocTag? - fun resolveKDocLink( + public fun resolveKDocLink( fromDescriptor: DeclarationDescriptor, qualifiedName: String, sourceSet: DokkaConfiguration.DokkaSourceSet, diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KLibService.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KLibService.kt index 1a84e779..fc173298 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KLibService.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/KLibService.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.storage.StorageManager @InternalDokkaApi -interface KLibService { - fun KotlinLibrary.createPackageFragmentProvider( +public interface KLibService { + public fun KotlinLibrary.createPackageFragmentProvider( storageManager: StorageManager, metadataModuleDescriptorFactory: KlibMetadataModuleDescriptorFactory, languageVersionSettings: LanguageVersionSettings, @@ -23,5 +23,5 @@ interface KLibService { lookupTracker: LookupTracker ): PackageFragmentProvider? - fun isAnalysisCompatible(kotlinLibrary: KotlinLibrary): Boolean + public fun isAnalysisCompatible(kotlinLibrary: KotlinLibrary): Boolean } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/MockApplicationHack.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/MockApplicationHack.kt index befbce02..39ca666b 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/MockApplicationHack.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/MockApplicationHack.kt @@ -8,6 +8,6 @@ import com.intellij.mock.MockApplication import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -interface MockApplicationHack { // ¯\_(ツ)_/¯ - fun hack(mockApplication: MockApplication) +public interface MockApplicationHack { // ¯\_(ツ)_/¯ + public fun hack(mockApplication: MockApplication) } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisContext.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisContext.kt index 50f40aa0..917a86e7 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisContext.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisContext.kt @@ -6,6 +6,7 @@ package org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.configuration import com.intellij.openapi.project.Project import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.InternalDokkaApi import org.jetbrains.dokka.Platform import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.AnalysisContextCreator import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.CompilerDescriptorAnalysisPlugin @@ -92,9 +93,10 @@ internal class DokkaMessageCollector(private val logger: DokkaLogger) : MessageC override fun hasErrors() = seenErrors } -interface AnalysisContext : Closeable { - val environment: KotlinCoreEnvironment - val resolveSession: ResolveSession - val moduleDescriptor: ModuleDescriptor - val project: Project +@InternalDokkaApi +public interface AnalysisContext : Closeable { + public val environment: KotlinCoreEnvironment + public val resolveSession: ResolveSession + public val moduleDescriptor: ModuleDescriptor + public val project: Project } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt index e0fa157c..5a0fc396 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt @@ -90,7 +90,7 @@ internal const val JAR_SEPARATOR = "!/" * $body: optional and can be used to configure environment without creating local variable */ @InternalDokkaApi -class AnalysisEnvironment( +public class AnalysisEnvironment( private val messageCollector: MessageCollector, internal val analysisPlatform: Platform, private val mockApplicationHack: MockApplicationHack, diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/KotlinAnalysis.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/KotlinAnalysis.kt index 1f7df3f0..4e6f42c9 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/KotlinAnalysis.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/KotlinAnalysis.kt @@ -59,15 +59,15 @@ internal fun SamplesKotlinAnalysis( return EnvironmentKotlinAnalysis(environments, projectKotlinAnalysis) } @DokkaPluginApiPreview -data class DokkaAnalysisConfiguration( +public data class DokkaAnalysisConfiguration( /** * Only for common platform ignore BuiltIns for StdLib since it can cause a conflict * between BuiltIns from a compiler and ones from source code. */ val ignoreCommonBuiltIns: Boolean = DEFAULT_IGNORE_COMMON_BUILT_INS ): ConfigurableBlock { - companion object { - const val DEFAULT_IGNORE_COMMON_BUILT_INS = false + public companion object { + public const val DEFAULT_IGNORE_COMMON_BUILT_INS: Boolean = false } } @@ -75,11 +75,11 @@ data class DokkaAnalysisConfiguration( * First child delegation. It does not close [parent]. */ @InternalDokkaApi -abstract class KotlinAnalysis( +public abstract class KotlinAnalysis( private val parent: KotlinAnalysis? = null ) : Closeable { - operator fun get(key: DokkaSourceSet): AnalysisContext { + public operator fun get(key: DokkaSourceSet): AnalysisContext { return get(key.sourceSetID) } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/impl/KotlinSampleProvider.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/impl/KotlinSampleProvider.kt index 38037c1d..5199abf5 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/impl/KotlinSampleProvider.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/impl/KotlinSampleProvider.kt @@ -24,7 +24,9 @@ import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.lazy.ResolveSession -class KotlinSampleProviderFactory(val context: DokkaContext): SampleProviderFactory { +public class KotlinSampleProviderFactory( + public val context: DokkaContext +): SampleProviderFactory { override fun build(): SampleProvider { return KotlinSampleProvider(context) } @@ -35,7 +37,9 @@ class KotlinSampleProviderFactory(val context: DokkaContext): SampleProviderFact * with [processBody] and [processImports] */ @InternalDokkaApi -open class KotlinSampleProvider(val context: DokkaContext): SampleProvider { +public open class KotlinSampleProvider( + public val context: DokkaContext +): SampleProvider { private val kDocFinder: KDocFinder = context.plugin().querySingle { kdocFinder } private val analysis = lazy { /** diff --git a/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/CoreKotlinCacheService.kt b/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/CoreKotlinCacheService.kt index 7cda9b70..2a299009 100644 --- a/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/CoreKotlinCacheService.kt +++ b/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/CoreKotlinCacheService.kt @@ -25,7 +25,7 @@ internal class CoreKotlinCacheService(private val resolutionFacade: DokkaResolut override fun getResolutionFacadeByFile( file: PsiFile, - platform: org.jetbrains.kotlin.platform.TargetPlatform + platform: TargetPlatform ): ResolutionFacade { return resolutionFacade } @@ -39,7 +39,7 @@ internal class CoreKotlinCacheService(private val resolutionFacade: DokkaResolut override fun getResolutionFacadeByModuleInfo( moduleInfo: ModuleInfo, - platform: org.jetbrains.kotlin.platform.TargetPlatform + platform: TargetPlatform ): ResolutionFacade { return resolutionFacade } diff --git a/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/IdeDescriptorAnalysisPlugin.kt b/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/IdeDescriptorAnalysisPlugin.kt index fe62f844..e170b740 100644 --- a/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/IdeDescriptorAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-descriptors/ide/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/ide/IdeDescriptorAnalysisPlugin.kt @@ -11,7 +11,7 @@ import org.jetbrains.dokka.plugability.DokkaPluginApiPreview import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement @InternalDokkaApi -class IdeDescriptorAnalysisPlugin : DokkaPlugin() { +public class IdeDescriptorAnalysisPlugin : DokkaPlugin() { internal val ideKdocFinder by extending { plugin().kdocFinder providing ::IdePluginKDocFinder -- cgit