[kpm] Implement generic 'kotlin.debug' extra

^KT-52568 In Progress
This commit is contained in:
sebastian.sellmair
2022-06-13 14:25:25 +02:00
committed by Space
parent da288d926b
commit 01a4045c04
2 changed files with 27 additions and 0 deletions
@@ -8,6 +8,7 @@
package org.jetbrains.kotlin.gradle.kpm.idea
import org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi
import org.jetbrains.kotlin.gradle.kpm.idea.serialize.IdeaKpmExtrasSerializer
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmFragmentGranularMetadataResolverFactory
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension
import org.jetbrains.kotlin.tooling.core.UnsafeApi
@@ -95,4 +96,9 @@ internal fun IdeaKpmProjectModelBuilder.Companion.default(
effect = IdeaKpmMissingFileDependencyLogger,
constraint = IdeaKpmProjectModelBuilder.FragmentConstraint.unconstrained
)
registerExtrasSerializationExtension {
/* For transporting debugging breadcrumbs into the ide */
register(kotlinDebugKey, IdeaKpmExtrasSerializer.javaIoSerializable())
}
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.kpm.idea
import org.jetbrains.kotlin.tooling.core.Extras
import org.jetbrains.kotlin.tooling.core.MutableExtras
import org.jetbrains.kotlin.tooling.core.extrasKeyOf
internal val kotlinDebugKey = extrasKeyOf<Any>("kotlin.debug")
val Extras.kotlinDebug get() = this[kotlinDebugKey]
var MutableExtras.kotlinDebug: Any?
get() = this[kotlinDebugKey]
set(value) {
if (value != null) this[kotlinDebugKey] = value
else this.remove(kotlinDebugKey)
}