diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2022-10-13 18:35:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 18:35:25 +0300 |
commit | c065412fdc7ee94c0be64b48eedb9819965df307 (patch) | |
tree | 19bdb097b1eb13367657c6cb6fb5199099496b54 /kotlin-analysis/src | |
parent | 9fe122861006b2e3e945fa2e4d91513d48bffcf7 (diff) | |
download | dokka-c065412fdc7ee94c0be64b48eedb9819965df307.tar.gz dokka-c065412fdc7ee94c0be64b48eedb9819965df307.tar.bz2 dokka-c065412fdc7ee94c0be64b48eedb9819965df307.zip |
Ignore BuiltIns for StdLib (#2658)
Diffstat (limited to 'kotlin-analysis/src')
3 files changed, 26 insertions, 10 deletions
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt index 044a4f07..0cae4e89 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt @@ -19,10 +19,7 @@ import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.dokka.Platform import org.jetbrains.dokka.analysis.resolve.* import org.jetbrains.kotlin.analyzer.* -import org.jetbrains.kotlin.analyzer.common.CommonAnalysisParameters -import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer -import org.jetbrains.kotlin.analyzer.common.CommonPlatformAnalyzerServices -import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory +import org.jetbrains.kotlin.analyzer.common.* import org.jetbrains.kotlin.builtins.DefaultBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns @@ -179,7 +176,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl ) } - fun createResolutionFacade(environment: KotlinCoreEnvironment): Pair<DokkaResolutionFacade, DokkaResolutionFacade> { + fun createResolutionFacade(environment: KotlinCoreEnvironment, ignoreCommonBuiltIns: Boolean = false): Pair<DokkaResolutionFacade, DokkaResolutionFacade> { val projectContext = ProjectContext(environment.project, "Dokka") val sourceFiles = environment.getSourceFiles() @@ -218,6 +215,15 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl override val platform: TargetPlatform = targetPlatform override fun dependencies(): List<ModuleInfo> = listOf(this, library) + extraModuleDependencies + + /** + * Only for common platform ignore BuiltIns for StdLib since it can cause a conflict + * between BuiltIns from a compiler and ones from source code. + */ + override fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns { + return if (analysisPlatform == Platform.common && ignoreCommonBuiltIns) ModuleInfo.DependencyOnBuiltIns.NONE + else super.dependencyOnBuiltIns() + } } val sourcesScope = createSourceModuleSearchScope(environment.project, sourceFiles) diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt index 60ad3315..b946c5bd 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt @@ -8,12 +8,12 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.utils.PathUtil internal fun createEnvironmentAndFacade( logger: DokkaLogger, sourceSets: List<DokkaConfiguration.DokkaSourceSet>, - sourceSet: DokkaConfiguration.DokkaSourceSet + sourceSet: DokkaConfiguration.DokkaSourceSet, + analysisConfiguration: DokkaAnalysisConfiguration ): EnvironmentAndFacade = AnalysisEnvironment(DokkaMessageCollector(logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { @@ -28,7 +28,8 @@ internal fun createEnvironmentAndFacade( loadLanguageVersionSettings(sourceSet.languageVersion, sourceSet.apiVersion) val environment = createCoreEnvironment() - val (facade, _) = createResolutionFacade(environment) + + val (facade, _) = createResolutionFacade(environment, analysisConfiguration.ignoreCommonBuiltIns) EnvironmentAndFacade(environment, facade) } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt index e7c26c25..a188e3f9 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt @@ -8,18 +8,27 @@ import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.DokkaLogger -fun KotlinAnalysis(sourceSets: List<DokkaSourceSet>, logger: DokkaLogger): KotlinAnalysis { +fun KotlinAnalysis(sourceSets: List<DokkaSourceSet>, logger: DokkaLogger, analysisConfiguration: DokkaAnalysisConfiguration = DokkaAnalysisConfiguration()): KotlinAnalysis { val environments = sourceSets.associateWith { sourceSet -> createEnvironmentAndFacade( logger = logger, sourceSets = sourceSets, - sourceSet = sourceSet + sourceSet = sourceSet, + analysisConfiguration = analysisConfiguration ) } return KotlinAnalysisImpl(environments) } +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 = false +) + @Deprecated(message = "Construct using list of DokkaSourceSets and logger", replaceWith = ReplaceWith("KotlinAnalysis(context.configuration.sourceSets, context.logger)") ) |