@@ -27,6 +27,7 @@ import kotlin.reflect.full.superclasses
2727import kotlin.reflect.jvm.jvmErasure
2828import kotlin.reflect.typeOf
2929import kotlin.time.Instant
30+ import kotlin.uuid.Uuid
3031
3132internal class ReplCodeGeneratorImpl : ReplCodeGenerator {
3233
@@ -120,24 +121,34 @@ internal class ReplCodeGeneratorImpl : ReplCodeGenerator {
120121 result.newMarkers.forEach {
121122 generatedMarkers[it.name] = it
122123 }
123- return if (schema.hasExperimentalInstant()) {
124+
125+ val optIns = buildString {
126+ if (schema.hasExperimentalInstant()) appendLine(" @file:OptIn(kotlin.time.ExperimentalTime::class)" )
127+ if (schema.hasExperimentalUuid()) appendLine(" @file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)" )
128+ }
129+
130+ return if (optIns.isNotEmpty()) {
124131 result.code.copy(
125- declarations = " @file:OptIn(kotlin.time.ExperimentalTime::class) \n " + result.code.declarations,
132+ declarations = optIns + " \n " + result.code.declarations,
126133 )
127134 } else {
128135 result.code
129136 }
130137 }
131138
132- private fun DataFrameSchema.hasExperimentalInstant ( ): Boolean =
139+ private fun DataFrameSchema.hasColumnOfType ( type : KType ): Boolean =
133140 columns.values.any { column ->
134141 when (column) {
135- is ColumnSchema .Frame -> column.schema.hasExperimentalInstant( )
136- is ColumnSchema .Group -> column.schema.hasExperimentalInstant( )
137- is ColumnSchema .Value -> column.type.isSubtypeOf(typeOf< Instant ?>() )
142+ is ColumnSchema .Frame -> column.schema.hasColumnOfType(type )
143+ is ColumnSchema .Group -> column.schema.hasColumnOfType(type )
144+ is ColumnSchema .Value -> column.type.isSubtypeOf(type )
138145 }
139146 }
140147
148+ private fun DataFrameSchema.hasExperimentalInstant (): Boolean = hasColumnOfType(typeOf<Instant ?>())
149+
150+ private fun DataFrameSchema.hasExperimentalUuid (): Boolean = hasColumnOfType(typeOf<Uuid ?>())
151+
141152 override fun process (markerClass : KClass <* >): Code {
142153 val newMarkers = mutableListOf<Marker >()
143154
0 commit comments