[KPM] Consistently use uppercase factory style for idea model builders

KT-51386
This commit is contained in:
sebastian.sellmair
2022-03-16 10:55:27 +01:00
committed by Space
parent 03cf978b77
commit 85998f8857
6 changed files with 19 additions and 19 deletions
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.gradle.kpm.idea
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
internal fun KotlinCompilationOutput.toIdeaKotlinCompilationOutputs(): IdeaKotlinCompilationOutput { internal fun IdeaKotlinCompilationOutput(compilation: KotlinCompilationOutput): IdeaKotlinCompilationOutput {
return IdeaKotlinCompilationOutputImpl( return IdeaKotlinCompilationOutputImpl(
classesDirs = this.classesDirs.toSet(), classesDirs = compilation.classesDirs.toSet(),
resourcesDir = this.resourcesDir resourcesDir = compilation.resourcesDir
) )
} }
@@ -16,8 +16,8 @@ internal fun IdeaKotlinProjectModelBuildingContext.IdeaKotlinFragment(fragment:
private fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinFragment(fragment: KotlinGradleFragment): IdeaKotlinFragment { private fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinFragment(fragment: KotlinGradleFragment): IdeaKotlinFragment {
return IdeaKotlinFragmentImpl( return IdeaKotlinFragmentImpl(
coordinates = IdeaKotlinFragmentCoordinates(fragment), coordinates = IdeaKotlinFragmentCoordinates(fragment),
platforms = fragment.containingVariants.map { variant -> buildIdeaKotlinPlatform(variant) }.toSet(), platforms = fragment.containingVariants.map { variant -> IdeaKotlinPlatform(variant) }.toSet(),
languageSettings = fragment.languageSettings.toIdeaKotlinLanguageSettings(), languageSettings = IdeaKotlinLanguageSettings(fragment.languageSettings),
dependencies = dependencyResolver.resolve(fragment).toList(), dependencies = dependencyResolver.resolve(fragment).toList(),
sourceDirectories = fragment.kotlinSourceRoots.sourceDirectories.files.toList().map { file -> IdeaKotlinSourceDirectoryImpl(file) }, sourceDirectories = fragment.kotlinSourceRoots.sourceDirectories.files.toList().map { file -> IdeaKotlinSourceDirectoryImpl(file) },
resourceDirectories = emptyList(), resourceDirectories = emptyList(),
@@ -28,8 +28,8 @@ private fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinFragment(fragme
private fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinVariant(variant: KotlinGradleVariant): IdeaKotlinVariant { private fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinVariant(variant: KotlinGradleVariant): IdeaKotlinVariant {
return IdeaKotlinVariantImpl( return IdeaKotlinVariantImpl(
fragment = buildIdeaKotlinFragment(variant), fragment = buildIdeaKotlinFragment(variant),
platform = buildIdeaKotlinPlatform(variant), platform = IdeaKotlinPlatform(variant),
variantAttributes = variant.variantAttributes.mapKeys { (key, _) -> key.uniqueName }, variantAttributes = variant.variantAttributes.mapKeys { (key, _) -> key.uniqueName },
compilationOutputs = variant.compilationOutputs.toIdeaKotlinCompilationOutputs() compilationOutputs = IdeaKotlinCompilationOutput(variant.compilationOutputs)
) )
} }
@@ -8,15 +8,15 @@ package org.jetbrains.kotlin.gradle.kpm.idea
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
import org.jetbrains.kotlin.project.model.LanguageSettings import org.jetbrains.kotlin.project.model.LanguageSettings
internal fun LanguageSettings.toIdeaKotlinLanguageSettings(): IdeaKotlinLanguageSettings { internal fun IdeaKotlinLanguageSettings(languageSettings: LanguageSettings): IdeaKotlinLanguageSettings {
return IdeaKotlinLanguageSettingsImpl( return IdeaKotlinLanguageSettingsImpl(
languageVersion = languageVersion, languageVersion = languageSettings.languageVersion,
apiVersion = apiVersion, apiVersion = languageSettings.apiVersion,
isProgressiveMode = progressiveMode, isProgressiveMode = languageSettings.progressiveMode,
enabledLanguageFeatures = enabledLanguageFeatures.toSet(), enabledLanguageFeatures = languageSettings.enabledLanguageFeatures.toSet(),
optInAnnotationsInUse = optInAnnotationsInUse.toSet(), optInAnnotationsInUse = languageSettings.optInAnnotationsInUse.toSet(),
compilerPluginArguments = (this as? DefaultLanguageSettingsBuilder)?.compilerPluginArguments?.toList().orEmpty(), compilerPluginArguments = (languageSettings as? DefaultLanguageSettingsBuilder)?.compilerPluginArguments?.toList().orEmpty(),
compilerPluginClasspath = (this as? DefaultLanguageSettingsBuilder)?.compilerPluginClasspath?.toList().orEmpty(), compilerPluginClasspath = (languageSettings as? DefaultLanguageSettingsBuilder)?.compilerPluginClasspath?.toList().orEmpty(),
freeCompilerArgs = (this as? DefaultLanguageSettingsBuilder)?.freeCompilerArgs?.toList().orEmpty() freeCompilerArgs = (languageSettings as? DefaultLanguageSettingsBuilder)?.freeCompilerArgs?.toList().orEmpty()
) )
} }
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.konan.target.HostManager
@Suppress("unused") @Suppress("unused")
/* Receiver acts as scope, or key to that function */ /* Receiver acts as scope, or key to that function */
internal fun IdeaKotlinProjectModelBuildingContext.buildIdeaKotlinPlatform(variant: KotlinGradleVariant): IdeaKotlinPlatform { internal fun IdeaKotlinProjectModelBuildingContext.IdeaKotlinPlatform(variant: KotlinGradleVariant): IdeaKotlinPlatform {
when (variant) { when (variant) {
is KotlinJvmVariant -> return IdeaKotlinPlatform.jvm(variant.compilationData.kotlinOptions.jvmTarget ?: JvmTarget.DEFAULT.name) is KotlinJvmVariant -> return IdeaKotlinPlatform.jvm(variant.compilationData.kotlinOptions.jvmTarget ?: JvmTarget.DEFAULT.name)
is KotlinNativeVariantInternal -> return IdeaKotlinPlatform.native(variant.konanTarget.name) is KotlinNativeVariantInternal -> return IdeaKotlinPlatform.native(variant.konanTarget.name)
@@ -129,7 +129,7 @@ interface IdeaKotlinProjectModelBuilder {
companion object companion object
} }
internal fun IdeaKotlinProjectModelBuildingContext.toIdeaKotlinProjectModel(extension: KotlinPm20ProjectExtension): IdeaKotlinProjectModel { internal fun IdeaKotlinProjectModelBuildingContext.IdeaKotlinProjectModel(extension: KotlinPm20ProjectExtension): IdeaKotlinProjectModel {
return IdeaKotlinProjectModelImpl( return IdeaKotlinProjectModelImpl(
gradlePluginVersion = extension.project.getKotlinPluginVersion(), gradlePluginVersion = extension.project.getKotlinPluginVersion(),
coreLibrariesVersion = extension.coreLibrariesVersion, coreLibrariesVersion = extension.coreLibrariesVersion,
@@ -71,7 +71,7 @@ internal class IdeaKotlinProjectModelBuilderImpl @UnsafeApi("Use factory methods
} }
override fun buildIdeaKotlinProjectModel(): IdeaKotlinProjectModel { override fun buildIdeaKotlinProjectModel(): IdeaKotlinProjectModel {
return Context().toIdeaKotlinProjectModel(extension) return Context().IdeaKotlinProjectModel(extension)
} }
override fun canBuild(modelName: String): Boolean = override fun canBuild(modelName: String): Boolean =