Skip to content

Commit cc5222c

Browse files
committed
[Compiler plugin] Remove redundant arguments that are equal to default value
1 parent 24457b4 commit cc5222c

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/ExpectedArgumentDelegates.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fun <T> AbstractInterpreter<T>.dataFrame(
2121
fun <T> AbstractInterpreter<T>.varargString(
2222
name: ArgumentName? = null,
2323
defaultValue: DefaultValue<List<String>> = Absent
24-
): ExpectedArgumentProvider<List<String>> = arg(name, lens = Interpreter.Value, defaultValue = defaultValue)
2524

2625
fun <T> AbstractInterpreter<T>.renameClause(
2726
name: ArgumentName? = null
@@ -38,40 +37,40 @@ fun <T> AbstractInterpreter<T>.type(
3837
fun <T, E : Enum<E>> AbstractInterpreter<T>.enum(
3938
name: ArgumentName? = null,
4039
defaultValue: DefaultValue<E> = Absent
41-
): ExpectedArgumentProvider<E> = argConvert(name = name, lens = Interpreter.Value, defaultValue = defaultValue) { it: DataFrameCallableId ->
40+
): ExpectedArgumentProvider<E> = argConvert(name = name, defaultValue = defaultValue) { it: DataFrameCallableId ->
4241
val forName: Class<*> = Class.forName("${it.packageName}.${it.className}")
4342
@Suppress("UNCHECKED_CAST")
4443
java.lang.Enum.valueOf(forName as Class<out Enum<*>>, it.callableName) as E
4544
}
4645

4746
fun <T> AbstractInterpreter<T>.columnAccessor(
4847
name: ArgumentName? = null
49-
): ExpectedArgumentProvider<ColumnAccessorApproximation> = arg(name, lens = Interpreter.Value)
48+
): ExpectedArgumentProvider<ColumnAccessorApproximation> = arg(name)
5049

5150
fun <T> AbstractInterpreter<T>.dataColumn(
5251
name: ArgumentName? = null
53-
): ExpectedArgumentProvider<SimpleCol> = arg(name, lens = Interpreter.Value)
52+
): ExpectedArgumentProvider<SimpleCol> = arg(name)
5453

5554
fun <T> AbstractInterpreter<T>.insertClause(
5655
name: ArgumentName? = null
57-
): ExpectedArgumentProvider<InsertClauseApproximation> = arg(name, lens = Interpreter.Value)
56+
): ExpectedArgumentProvider<InsertClauseApproximation> = arg(name)
5857

5958
internal fun <T> AbstractInterpreter<T>.columnPath(
6059
name: ArgumentName? = null
61-
): ExpectedArgumentProvider<ColumnPathApproximation> = arg(name, lens = Interpreter.Value)
6260

6361
internal fun <T> AbstractInterpreter<T>.columnWithPath(
6462
name: ArgumentName? = null
6563
): ExpectedArgumentProvider<ColumnWithPathApproximation> = arg(name, lens = Interpreter.Value)
64+
): ExpectedArgumentProvider<ColumnPathApproximation> = arg(name)
6665

6766
fun <T> AbstractInterpreter<T>.kproperty(
6867
name: ArgumentName? = null
69-
): ExpectedArgumentProvider<KPropertyApproximation> = arg(name, lens = Interpreter.Value)
68+
): ExpectedArgumentProvider<KPropertyApproximation> = arg(name)
7069

7170
internal fun <T> AbstractInterpreter<T>.string(
7271
name: ArgumentName? = null
7372
): ExpectedArgumentProvider<String> =
74-
arg(name, lens = Interpreter.Value)
73+
arg(name)
7574

7675
internal fun <T> AbstractInterpreter<T>.dsl(
7776
name: ArgumentName? = null

plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/add.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.jetbrains.kotlinx.dataframe.plugin.extensions.Marker
44
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter
55
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractSchemaModificationInterpreter
66
import org.jetbrains.kotlinx.dataframe.plugin.impl.Arguments
7-
import org.jetbrains.kotlinx.dataframe.plugin.impl.Interpreter
87
import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema
98
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleCol
109
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleColumnGroup
@@ -27,7 +26,7 @@ class Add : AbstractSchemaModificationInterpreter() {
2726
}
2827

2928
class From : AbstractInterpreter<Unit>() {
30-
val Arguments.dsl: AddDslApproximation by arg(lens = Interpreter.Value)
29+
val Arguments.dsl: AddDslApproximation by arg()
3130
val Arguments.receiver: String by string()
3231
val Arguments.type: TypeApproximation by type(name("expression"))
3332

@@ -37,7 +36,7 @@ class From : AbstractInterpreter<Unit>() {
3736
}
3837

3938
class Into : AbstractInterpreter<Unit>() {
40-
val Arguments.dsl: AddDslApproximation by arg(lens = Interpreter.Value)
39+
val Arguments.dsl: AddDslApproximation by arg()
4140
val Arguments.receiver: TypeApproximation by type()
4241
val Arguments.name: String by string()
4342

@@ -60,7 +59,7 @@ class AddWithDsl : AbstractSchemaModificationInterpreter() {
6059
}
6160

6261
class AddDslStringInvoke : AbstractInterpreter<Unit>() {
63-
val Arguments.dsl: AddDslApproximation by arg(lens = Interpreter.Value)
62+
val Arguments.dsl: AddDslApproximation by arg()
6463
val Arguments.receiver: String by string()
6564
val Arguments.body by dsl()
6665

plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/stdlib.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ class PairConstructor : AbstractInterpreter<Pair<*, *>>() {
2222
}
2323

2424
class TrimMargin : AbstractInterpreter<String>() {
25-
val Arguments.receiver: String by arg(lens = Interpreter.Value)
26-
val Arguments.marginPrefix: String by arg(lens = Interpreter.Value, defaultValue = Present("|"))
25+
val Arguments.receiver: String by arg()
26+
val Arguments.marginPrefix: String by arg(defaultValue = Present("|"))
2727

2828
override fun Arguments.interpret(): String {
2929
return receiver.trimMargin(marginPrefix)
3030
}
3131
}
3232

3333
class TrimIndent : AbstractInterpreter<String>() {
34-
val Arguments.receiver: String by arg(lens = Interpreter.Value)
34+
val Arguments.receiver: String by arg()
3535

3636
override fun Arguments.interpret(): String {
3737
return receiver.trimIndent()

0 commit comments

Comments
 (0)