Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @AccessApiOverload annotations for API methods #1011

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnsContainer
import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
Expand All @@ -30,18 +31,21 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
* @include [CommonColumnReferenceInvokeDocs]
* @return The [DataColumn] this [Column Reference][ColumnReference] or [-Accessor][ColumnAccessor] points to.
*/
@AccessApiOverload
public operator fun <C> ColumnReference<C>.invoke(): DataColumn<C> = get(this)

/**
* @include [CommonColumnReferenceInvokeDocs]
* @return The [ColumnGroup] this [Column Reference][ColumnReference] or [-Accessor][ColumnAccessor] points to.
*/
@AccessApiOverload
public operator fun <T> ColumnReference<DataRow<T>>.invoke(): ColumnGroup<T> = get(this)

/**
* @include [CommonColumnReferenceInvokeDocs]
* @return The [FrameColumn] this [Column Reference][ColumnReference] or [-Accessor][ColumnAccessor] points to.
*/
@AccessApiOverload
public operator fun <T> ColumnReference<DataFrame<T>>.invoke(): FrameColumn<T> = get(this)

/**
Expand Down Expand Up @@ -70,18 +74,21 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
* @include [CommonKPropertyInvokeDocs]
* @return The [DataColumn] this [KProperty Accessor][KProperty] points to.
*/
@AccessApiOverload
public operator fun <T> KProperty<T>.invoke(): DataColumn<T> = this@ColumnSelectionDsl[this]

/**
* @include [CommonKPropertyInvokeDocs]
* @return The [ColumnGroup] this [KProperty Accessor][KProperty] points to.
*/
@AccessApiOverload
public operator fun <T> KProperty<DataRow<T>>.invoke(): ColumnGroup<T> = this@ColumnSelectionDsl[this]

/**
* @include [CommonKPropertyInvokeDocs]
* @return The [FrameColumn] this [KProperty Accessor][KProperty] points to.
*/
@AccessApiOverload
public operator fun <T> KProperty<DataFrame<T>>.invoke(): FrameColumn<T> = this@ColumnSelectionDsl[this]

/**
Expand All @@ -105,6 +112,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowGet")
@AccessApiOverload
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<R>): DataColumn<R> = invoke()[column]

/**
Expand All @@ -113,6 +121,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowGet")
@AccessApiOverload
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<DataRow<R>>): ColumnGroup<R> =
invoke()[column]

Expand All @@ -122,26 +131,30 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowGet")
@AccessApiOverload
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<DataFrame<R>>): FrameColumn<R> =
invoke()[column]

/**
* @include [CommonKPropertyGetDocs]
* @return The [DataColumn] these [KProperty Accessors][KProperty] point to.
*/
@AccessApiOverload
public operator fun <T, R> KProperty<T>.get(column: KProperty<R>): DataColumn<R> = invoke().asColumnGroup()[column]

/**
* @include [CommonKPropertyGetDocs]
* @return The [ColumnGroup] these [KProperty Accessors][KProperty] point to.
*/
@AccessApiOverload
public operator fun <T, R> KProperty<T>.get(column: KProperty<DataRow<R>>): ColumnGroup<R> =
invoke().asColumnGroup()[column]

/**
* @include [CommonKPropertyGetDocs]
* @return The [FrameColumn] these [KProperty Accessors][KProperty] point to.
*/
@AccessApiOverload
public operator fun <T, R> KProperty<T>.get(column: KProperty<DataFrame<R>>): FrameColumn<R> =
invoke().asColumnGroup()[column]

Expand Down
49 changes: 49 additions & 0 deletions core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
Expand Down Expand Up @@ -263,6 +264,7 @@ public interface AllExceptColumnsSelectionDsl {
* @set [ColumnSetInfixDocs.ArgumentArg1] `Person::age`
* @set [ColumnSetInfixDocs.ArgumentArg2] `Person::name`
*/
@AccessApiOverload
public infix fun <C> ColumnSet<C>.except(other: KProperty<C>): ColumnSet<C> = except(column(other))

/**
Expand All @@ -272,6 +274,7 @@ public interface AllExceptColumnsSelectionDsl {
* @set [ColumnSetVarargDocs.ArgumentArg1] `(Person::age, Person::height)`
* @set [ColumnSetVarargDocs.ArgumentArg2] `(Person::name)`
*/
@AccessApiOverload
public fun <C> ColumnSet<C>.except(vararg others: KProperty<C>): ColumnSet<C> = except(others.toColumnSet())

/**
Expand Down Expand Up @@ -350,6 +353,7 @@ public interface AllExceptColumnsSelectionDsl {
* @set [ColumnsSelectionDslDocs.ArgumentArg1] `(Person::age, Person::height)`
* @set [ColumnsSelectionDslDocs.ArgumentArg2] `(Person::name)`
*/
@AccessApiOverload
public fun ColumnsSelectionDsl<*>.allExcept(vararg others: KProperty<*>): ColumnSet<*> =
asSingleColumn().allColsExceptInternal(others.toColumnSet())

Expand Down Expand Up @@ -493,6 +497,7 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ColumnGroupDocs.SingleColumnReceiverArgs]
* @include [ColumnGroupDocs.KPropertyArgs]
*/
@AccessApiOverload
public fun SingleColumn<DataRow<*>>.allColsExcept(vararg others: KProperty<*>): ColumnSet<*> =
allColsExceptInternal(others.toColumnSet())

Expand Down Expand Up @@ -545,6 +550,7 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ColumnGroupDocs.StringReceiverArgs]
* @include [ColumnGroupDocs.KPropertyArgs]
*/
@AccessApiOverload
public fun String.allColsExcept(vararg others: KProperty<*>): ColumnSet<*> =
columnGroup(this).allColsExceptInternal(others.toColumnSet())

Expand Down Expand Up @@ -597,6 +603,7 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ColumnGroupDocs.KPropertyReceiverArgs]
* @include [ColumnGroupDocs.KPropertyArgs]
*/
@AccessApiOverload
public fun KProperty<*>.allColsExcept(vararg others: KProperty<*>): ColumnSet<*> =
columnGroup(this).allColsExceptInternal(others.toColumnSet())

Expand Down Expand Up @@ -649,6 +656,7 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ColumnGroupDocs.ColumnPathReceiverArgs]
* @include [ColumnGroupDocs.KPropertyArgs]
*/
@AccessApiOverload
public fun ColumnPath.allColsExcept(vararg others: KProperty<*>): ColumnSet<*> =
columnGroup(this).allColsExceptInternal(others.toColumnSet())

Expand Down Expand Up @@ -731,13 +739,15 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public infix fun <C> SingleColumn<DataRow<C>>.exceptNew(other: KProperty<C>): SingleColumn<DataRow<C>> =
exceptExperimentalInternal(column(other))

/**
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public fun <C> SingleColumn<DataRow<C>>.exceptNew(vararg others: KProperty<*>): SingleColumn<DataRow<C>> =
exceptExperimentalInternal(others.toColumnSet())

Expand Down Expand Up @@ -798,13 +808,15 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public infix fun String.exceptNew(other: KProperty<*>): SingleColumn<DataRow<*>> =
columnGroup(this).exceptExperimentalInternal(column(other))

/**
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public fun String.exceptNew(vararg others: KProperty<*>): SingleColumn<DataRow<*>> =
columnGroup(this).exceptExperimentalInternal(others.toColumnSet())

Expand Down Expand Up @@ -883,13 +895,15 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public infix fun <C> KProperty<C>.exceptNew(other: KProperty<*>): SingleColumn<DataRow<C>> =
columnGroup(this).exceptExperimentalInternal(column(other))

/**
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public fun <C> KProperty<C>.exceptNew(vararg others: KProperty<*>): SingleColumn<DataRow<C>> =
columnGroup(this).exceptExperimentalInternal(others.toColumnSet())

Expand All @@ -899,6 +913,7 @@ public interface AllExceptColumnsSelectionDsl {
@ExperimentalExceptCsDsl
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowExceptNew")
@AccessApiOverload
public infix fun <C> KProperty<DataRow<C>>.exceptNew(other: KProperty<*>): SingleColumn<DataRow<C>> =
columnGroup(this).exceptExperimentalInternal(column(other))

Expand All @@ -908,6 +923,7 @@ public interface AllExceptColumnsSelectionDsl {
@ExperimentalExceptCsDsl
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowExceptNew")
@AccessApiOverload
public fun <C> KProperty<DataRow<C>>.exceptNew(vararg others: KProperty<*>): SingleColumn<DataRow<C>> =
columnGroup(this).exceptExperimentalInternal(others.toColumnSet())

Expand Down Expand Up @@ -986,10 +1002,12 @@ public interface AllExceptColumnsSelectionDsl {
* @include [ExperimentalExceptDocs]
*/
@ExperimentalExceptCsDsl
@AccessApiOverload
public infix fun ColumnPath.exceptNew(other: KProperty<*>): SingleColumn<DataRow<*>> =
columnGroup(this).exceptExperimentalInternal(column(other))

@ExperimentalExceptCsDsl
@AccessApiOverload
public fun ColumnPath.exceptNew(vararg others: KProperty<*>): SingleColumn<DataRow<*>> =
columnGroup(this).exceptExperimentalInternal(others.toColumnSet())

Expand Down
13 changes: 13 additions & 0 deletions core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/col.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor
import org.jetbrains.kotlinx.dataframe.ColumnGroupReference
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar
import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar.ColumnGroupName
import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar.ColumnSetName
Expand Down Expand Up @@ -163,11 +164,13 @@ public interface ColColumnsSelectionDsl<out _UNUSED> {
* {@set [CommonColDocs.Note] NOTE: This overload is an identity function and can be omitted.}
*/
@Deprecated(IDENTITY_FUNCTION, ReplaceWith(COL_REPLACE))
@AccessApiOverload
public fun <C> col(col: ColumnAccessor<C>): ColumnAccessor<C> = col

/**
* @include [ColReferenceDocs] {@set [CommonColDocs.ReceiverArg] myColumnGroup.}
*/
@AccessApiOverload
public fun <C> SingleColumn<DataRow<*>>.col(col: ColumnAccessor<C>): SingleColumn<C> =
this.ensureIsColumnGroup().transformSingle {
val child = it.getCol(col)
Expand All @@ -178,24 +181,28 @@ public interface ColColumnsSelectionDsl<out _UNUSED> {
/**
* @include [ColReferenceDocs] {@set [CommonColDocs.ReceiverArg] myColumnGroup.}
*/
@AccessApiOverload
public fun <C> AnyColumnGroupAccessor.col(col: ColumnAccessor<C>): ColumnAccessor<C> =
this.ensureIsColumnGroup().column(col.path())

/**
* @include [ColReferenceDocs] {@set [CommonColDocs.ReceiverArg] "myColumnGroup".}
*/
@AccessApiOverload
public fun <C> String.col(col: ColumnAccessor<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(col.path())

/**
* @include [ColReferenceDocs] {@set [CommonColDocs.ReceiverArg] Type::myColumnGroup.}
*/
@AccessApiOverload
public fun <C> KProperty<*>.col(col: ColumnAccessor<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(col.path())

/**
* @include [ColReferenceDocs] {@set [CommonColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
*/
@AccessApiOverload
public fun <C> ColumnPath.col(col: ColumnAccessor<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(col.path())

Expand Down Expand Up @@ -414,34 +421,40 @@ public interface ColColumnsSelectionDsl<out _UNUSED> {
/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg]}
*/
@AccessApiOverload
public fun <C> col(property: KProperty<C>): SingleColumn<C> = column(property)

/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg] myColumnGroup.}
*/
@AccessApiOverload
public fun <C> SingleColumn<DataRow<*>>.col(property: KProperty<C>): SingleColumn<C> = col<C>(property.name)

/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg] myColumnGroup.}
*/
@AccessApiOverload
public fun <C> AnyColumnGroupAccessor.col(property: KProperty<C>): ColumnAccessor<C> =
this.ensureIsColumnGroup().column(property)

/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg] "myColumnGroup".}
*/
@AccessApiOverload
public fun <C> String.col(property: KProperty<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(property)

/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg] Type::myColumnGroup.}
*/
@AccessApiOverload
public fun <C> KProperty<*>.col(property: KProperty<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(property)

/**
* @include [ColKPropertyDocs] {@set [CommonColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
*/
@AccessApiOverload
public fun <C> ColumnPath.col(property: KProperty<C>): ColumnAccessor<C> =
columnGroup(this).ensureIsColumnGroup().column(property)

Expand Down
Loading
Loading