Skip to content

Commit 526a7a2

Browse files
[Junie] shortcuts deprecation move to error in 1.1
1 parent 5d0b16a commit 526a7a2

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ import org.jetbrains.kotlinx.dataframe.indices
1717
import org.jetbrains.kotlinx.dataframe.ncol
1818
import org.jetbrains.kotlinx.dataframe.nrow
1919
import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API
20-
import org.jetbrains.kotlinx.dataframe.util.MESSAGE_SHORTCUT_1_0
20+
import org.jetbrains.kotlinx.dataframe.util.MESSAGE_SHORTCUT
21+
import org.jetbrains.kotlinx.dataframe.util.IS_EMPTY_REPLACE
22+
import org.jetbrains.kotlinx.dataframe.util.IS_NOT_EMPTY_REPLACE
23+
import org.jetbrains.kotlinx.dataframe.util.GET_ROW_REPLACE
24+
import org.jetbrains.kotlinx.dataframe.util.GET_ROWS_ITERABLE_REPLACE
25+
import org.jetbrains.kotlinx.dataframe.util.GET_ROWS_RANGE_REPLACE
26+
import org.jetbrains.kotlinx.dataframe.util.GET_ROW_OR_NULL_REPLACE
2127
import kotlin.experimental.ExperimentalTypeInference
2228
import kotlin.reflect.KProperty
2329
import kotlin.reflect.KType
2430

25-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("values().all { it == null }"), DeprecationLevel.ERROR)
31+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(IS_EMPTY_REPLACE), DeprecationLevel.WARNING)
2632
public fun AnyRow.isEmpty(): Boolean = owner.columns().all { it[index] == null }
2733

2834
@Suppress("DEPRECATION_ERROR")
29-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("values().any { it != null }"), DeprecationLevel.ERROR)
35+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(IS_NOT_EMPTY_REPLACE), DeprecationLevel.WARNING)
3036
public fun AnyRow.isNotEmpty(): Boolean = !isEmpty()
3137

3238
public inline fun <reified R> AnyRow.valuesOf(): List<R> = values().filterIsInstance<R>()
@@ -180,16 +186,16 @@ public fun AnyRow.columnNames(): List<String> = df().columnNames()
180186
public fun AnyRow.columnTypes(): List<KType> = df().columnTypes()
181187

182188
@Suppress("DEPRECATION_ERROR")
183-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("df().getRow(index)"), DeprecationLevel.ERROR)
189+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(GET_ROW_REPLACE), DeprecationLevel.WARNING)
184190
public fun <T> DataRow<T>.getRow(index: Int): DataRow<T> = getRowOrNull(index)!!
185191

186-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("df().getRows(indices)"), DeprecationLevel.ERROR)
192+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(GET_ROWS_ITERABLE_REPLACE), DeprecationLevel.WARNING)
187193
public fun <T> DataRow<T>.getRows(indices: Iterable<Int>): DataFrame<T> = df().getRows(indices)
188194

189-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("df().getRows(indices)"), DeprecationLevel.ERROR)
195+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(GET_ROWS_RANGE_REPLACE), DeprecationLevel.WARNING)
190196
public fun <T> DataRow<T>.getRows(indices: IntRange): DataFrame<T> = df().getRows(indices)
191197

192-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("df().getRowOrNull(index)"), DeprecationLevel.ERROR)
198+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(GET_ROW_OR_NULL_REPLACE), DeprecationLevel.WARNING)
193199
public fun <T> DataRow<T>.getRowOrNull(index: Int): DataRow<T>? {
194200
val df = df()
195201
return if (index >= 0 && index < df.nrow) df[index] else null
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.jetbrains.kotlinx.dataframe.api
22

33
import org.jetbrains.kotlinx.dataframe.DataFrame
4-
import org.jetbrains.kotlinx.dataframe.util.MESSAGE_SHORTCUT_1_0
4+
import org.jetbrains.kotlinx.dataframe.util.MESSAGE_SHORTCUT
5+
import org.jetbrains.kotlinx.dataframe.util.COPY_REPLACE
56

67
// region DataFrame
78

8-
@Deprecated(MESSAGE_SHORTCUT_1_0, ReplaceWith("columns().toDataFrame().cast()"), DeprecationLevel.ERROR)
9+
@Deprecated(MESSAGE_SHORTCUT, ReplaceWith(COPY_REPLACE), DeprecationLevel.WARNING)
910
public fun <T> DataFrame<T>.copy(): DataFrame<T> = columns().toDataFrame().cast()
1011

1112
// endregion

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import org.jetbrains.kotlinx.dataframe.impl.api.moveImpl
2323
import org.jetbrains.kotlinx.dataframe.impl.api.moveTo
2424
import org.jetbrains.kotlinx.dataframe.ncol
2525
import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API
26-
import org.jetbrains.kotlinx.dataframe.util.MESSAGE_SHORTCUT_1_0
2726
import org.jetbrains.kotlinx.dataframe.util.MOVE_TO_LEFT
2827
import org.jetbrains.kotlinx.dataframe.util.MOVE_TO_LEFT_REPLACE
2928
import org.jetbrains.kotlinx.dataframe.util.MOVE_TO_RIGHT

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ internal const val INSERT_AFTER_COL_PATH =
143143
"This `after()` overload will be removed in favor of `after { }` with Column Selection DSL. $MESSAGE_1_0"
144144
internal const val INSERT_AFTER_COL_PATH_REPLACE = "this.after { columnPath }"
145145

146-
internal const val MESSAGE_SHORTCUT_1_0 = "This shortcut is deprecated. $MESSAGE_1_0"
147-
148146
// endregion
149147

150148
// region WARNING in 1.0, ERROR in 1.1
@@ -247,6 +245,14 @@ internal const val ADD_VARARG_COLUMNS_REPLACE = "this.addAll(*columns)"
247245
internal const val ADD_VARARG_FRAMES = "Deprecated in favor of `addAll(vararg)` to improve completion. $MESSAGE_1_1"
248246
internal const val ADD_VARARG_FRAMES_REPLACE = "this.addAll(*dataFrames)"
249247

248+
internal const val IS_EMPTY_REPLACE = "values().all { it == null }"
249+
internal const val IS_NOT_EMPTY_REPLACE = "values().any { it != null }"
250+
internal const val GET_ROW_REPLACE = "df().getRow(index)"
251+
internal const val GET_ROWS_ITERABLE_REPLACE = "df().getRows(indices)"
252+
internal const val GET_ROWS_RANGE_REPLACE = "df().getRows(indices)"
253+
internal const val GET_ROW_OR_NULL_REPLACE = "df().getRowOrNull(index)"
254+
internal const val COPY_REPLACE = "columns().toDataFrame().cast()"
255+
250256
// endregion
251257

252258
// region keep across releases

0 commit comments

Comments
 (0)