Skip to content

Commit b83cbfc

Browse files
authored
Merge pull request #978 from Kotlin/nameStartsWithDeprecations
Bumped deprecations of `startsWith` and `endsWith` in CS DSL to Error
2 parents 9f185d7 + 59e9ef0 commit b83cbfc

File tree

2 files changed

+75
-23
lines changed

2 files changed

+75
-23
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
1212
import org.jetbrains.kotlinx.dataframe.documentation.Indent
1313
import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
1414
import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet
15+
import org.jetbrains.kotlinx.dataframe.util.COL_ENDS_WITH
16+
import org.jetbrains.kotlinx.dataframe.util.COL_ENDS_WITH_REPLACE
17+
import org.jetbrains.kotlinx.dataframe.util.COL_STARTS_WITH
18+
import org.jetbrains.kotlinx.dataframe.util.COL_STARTS_WITH_REPLACE
19+
import org.jetbrains.kotlinx.dataframe.util.ENDS_WITH
20+
import org.jetbrains.kotlinx.dataframe.util.ENDS_WITH_REPLACE
21+
import org.jetbrains.kotlinx.dataframe.util.STARTS_WITH
22+
import org.jetbrains.kotlinx.dataframe.util.STARTS_WITH_REPLACE
1523
import kotlin.reflect.KProperty
1624

1725
// region ColumnsSelectionDsl
@@ -339,17 +347,6 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
339347
@ExcludeFromSources
340348
private interface CommonNameStartsWithDocs
341349

342-
@Deprecated("Use nameStartsWith instead", ReplaceWith("this.nameStartsWith(prefix)"))
343-
public fun <C> ColumnSet<C>.startsWith(prefix: CharSequence): TransformableColumnSet<C> = nameStartsWith(prefix)
344-
345-
@Deprecated("Use nameStartsWith instead", ReplaceWith("this.nameStartsWith(prefix)"))
346-
public fun ColumnsSelectionDsl<*>.startsWith(prefix: CharSequence): TransformableColumnSet<*> =
347-
nameStartsWith(prefix)
348-
349-
@Deprecated("Use colsNameStartsWith instead", ReplaceWith("this.colsNameStartsWith(prefix)"))
350-
public fun SingleColumn<DataRow<*>>.startsWith(prefix: CharSequence): TransformableColumnSet<*> =
351-
colsNameStartsWith(prefix)
352-
353350
/**
354351
* @include [CommonNameStartsWithDocs]
355352
* @set [CommonNameStartsEndsDocs.ExampleArg]
@@ -436,18 +433,6 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
436433
@ExcludeFromSources
437434
private interface CommonNameEndsWithDocs
438435

439-
@Deprecated("Use nameEndsWith instead", ReplaceWith("this.nameEndsWith(suffix)"))
440-
@Suppress("UNCHECKED_CAST")
441-
public fun <C> ColumnSet<C>.endsWith(suffix: CharSequence): TransformableColumnSet<C> =
442-
colsInternal { it.name.endsWith(suffix) } as TransformableColumnSet<C>
443-
444-
@Deprecated("Use nameEndsWith instead", ReplaceWith("this.nameEndsWith(suffix)"))
445-
public fun ColumnsSelectionDsl<*>.endsWith(suffix: CharSequence): TransformableColumnSet<*> = nameEndsWith(suffix)
446-
447-
@Deprecated("Use colsNameEndsWith instead", ReplaceWith("this.colsNameEndsWith(suffix)"))
448-
public fun SingleColumn<DataRow<*>>.endsWith(suffix: CharSequence): TransformableColumnSet<*> =
449-
this.ensureIsColumnGroup().colsInternal { it.name.endsWith(suffix) }
450-
451436
/**
452437
* @include [CommonNameEndsWithDocs]
453438
* @set [CommonNameStartsEndsDocs.ExampleArg]
@@ -514,6 +499,57 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
514499
): TransformableColumnSet<*> = columnGroup(this).colsNameEndsWith(suffix, ignoreCase)
515500

516501
// endregion
502+
503+
// region deprecations
504+
505+
@Deprecated(
506+
message = STARTS_WITH,
507+
replaceWith = ReplaceWith(STARTS_WITH_REPLACE),
508+
level = DeprecationLevel.ERROR,
509+
)
510+
public fun <C> ColumnSet<C>.startsWith(prefix: CharSequence): TransformableColumnSet<C> = nameStartsWith(prefix)
511+
512+
@Deprecated(
513+
message = STARTS_WITH,
514+
replaceWith = ReplaceWith(STARTS_WITH_REPLACE),
515+
level = DeprecationLevel.ERROR,
516+
)
517+
public fun ColumnsSelectionDsl<*>.startsWith(prefix: CharSequence): TransformableColumnSet<*> =
518+
nameStartsWith(prefix)
519+
520+
@Deprecated(
521+
message = COL_STARTS_WITH,
522+
replaceWith = ReplaceWith(COL_STARTS_WITH_REPLACE),
523+
level = DeprecationLevel.ERROR,
524+
)
525+
public fun SingleColumn<DataRow<*>>.startsWith(prefix: CharSequence): TransformableColumnSet<*> =
526+
colsNameStartsWith(prefix)
527+
528+
@Deprecated(
529+
message = ENDS_WITH,
530+
replaceWith = ReplaceWith(ENDS_WITH_REPLACE),
531+
level = DeprecationLevel.ERROR,
532+
)
533+
@Suppress("UNCHECKED_CAST")
534+
public fun <C> ColumnSet<C>.endsWith(suffix: CharSequence): TransformableColumnSet<C> =
535+
colsInternal { it.name.endsWith(suffix) } as TransformableColumnSet<C>
536+
537+
@Deprecated(
538+
message = ENDS_WITH,
539+
replaceWith = ReplaceWith(ENDS_WITH_REPLACE),
540+
level = DeprecationLevel.ERROR,
541+
)
542+
public fun ColumnsSelectionDsl<*>.endsWith(suffix: CharSequence): TransformableColumnSet<*> = nameEndsWith(suffix)
543+
544+
@Deprecated(
545+
message = COL_ENDS_WITH,
546+
replaceWith = ReplaceWith(COL_ENDS_WITH_REPLACE),
547+
level = DeprecationLevel.ERROR,
548+
)
549+
public fun SingleColumn<DataRow<*>>.endsWith(suffix: CharSequence): TransformableColumnSet<*> =
550+
this.ensureIsColumnGroup().colsInternal { it.name.endsWith(suffix) }
551+
552+
// endregion
517553
}
518554

519555
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ package org.jetbrains.kotlinx.dataframe.util
77
* Level.ERROR -> Remove
88
*/
99

10+
// region WARNING in 0.14, ERROR in 0.15
11+
12+
private const val MESSAGE_0_15 = "Will be ERROR in 0.15."
13+
14+
internal const val STARTS_WITH = "Use nameStartsWith() instead. $MESSAGE_0_15"
15+
internal const val STARTS_WITH_REPLACE = "this.nameStartsWith(prefix)"
16+
17+
internal const val COL_STARTS_WITH = "Use colsNameStartsWith() instead. $MESSAGE_0_15"
18+
internal const val COL_STARTS_WITH_REPLACE = "this.colsNameStartsWith(prefix)"
19+
20+
internal const val ENDS_WITH = "Use nameEndsWith() instead. $MESSAGE_0_15"
21+
internal const val ENDS_WITH_REPLACE = "this.nameEndsWith(suffix)"
22+
23+
internal const val COL_ENDS_WITH = "Use colsNameEndsWith() instead. $MESSAGE_0_15"
24+
internal const val COL_ENDS_WITH_REPLACE = "this.colsNameEndsWith(suffix)"
25+
1026
// region WARNING in 0.15, ERROR in 0.16
1127

1228
private const val MESSAGE_0_16 = "Will be ERROR in 0.16."

0 commit comments

Comments
 (0)