generated from JavierSegoviaCordoba/kotlin-template-javiersc
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
KopyFunctions
to set the functions to be generated
- Loading branch information
1 parent
1cb47bb
commit 74ecc4b
Showing
20 changed files
with
388 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
### Added | ||
|
||
- `KopyFunctions` to set the functions that will be generated | ||
|
||
### Changed | ||
|
||
### Deprecated | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
kopy-args/common/main/kotlin/com/javiersc/kotlin/kopy/args/KopyFunctions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.javiersc.kotlin.kopy.args | ||
|
||
import java.io.Serializable | ||
|
||
public enum class KopyFunctions(public val value: String) : Serializable { | ||
All(value = "all"), | ||
Copy(value = "copy"), | ||
Invoke(value = "invoke"), | ||
; | ||
|
||
public companion object { | ||
|
||
public const val NAME: String = "KopyFunctions" | ||
public const val DESCRIPTION: String = "Kopy functions to be generated" | ||
|
||
public fun from(value: String): KopyFunctions = | ||
when (value) { | ||
All.name -> All | ||
All.value -> All | ||
Copy.name -> Copy | ||
Copy.value -> Copy | ||
Invoke.name -> Invoke | ||
Invoke.value -> Invoke | ||
else -> All | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
kopy-args/common/test/kotlin/com/javiersc/kotlin/kopy/args/KopyFunctionsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.javiersc.kotlin.kopy.args | ||
|
||
import io.kotest.matchers.shouldBe | ||
import kotlin.test.Test | ||
|
||
class KopyFunctionsTest { | ||
|
||
@Test | ||
fun `kopy functions`() { | ||
KopyFunctions.from("all") shouldBe KopyFunctions.All | ||
KopyFunctions.from("All") shouldBe KopyFunctions.All | ||
KopyFunctions.from("copy") shouldBe KopyFunctions.Copy | ||
KopyFunctions.from("Copy") shouldBe KopyFunctions.Copy | ||
KopyFunctions.from("invoke") shouldBe KopyFunctions.Invoke | ||
KopyFunctions.from("Invoke") shouldBe KopyFunctions.Invoke | ||
KopyFunctions.from("random") shouldBe KopyFunctions.All | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
kopy-compiler/main/kotlin/com/javiersc/kotlin/kopy/compiler/KopyKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.javiersc.kotlin.kopy.compiler | ||
|
||
import com.javiersc.kotlin.kopy.args.KopyFunctions | ||
import com.javiersc.kotlin.kopy.args.KopyVisibility | ||
import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
|
||
internal object KopyKey { | ||
val Visibility = CompilerConfigurationKey<KopyVisibility>(KopyVisibility.NAME) | ||
val Functions = CompilerConfigurationKey<KopyFunctions>(KopyFunctions.NAME) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
kopy-compiler/test-data/diagnostics-kopy-functions/all/all.fir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FILE: all.kt | ||
package com.javiersc.kotlin.kopy.playground | ||
|
||
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Foo : R|kotlin/Any| { | ||
public constructor(number: R|kotlin/Int|, letter: R|kotlin/Char|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
public final val number: R|kotlin/Int| = R|<local>/number| | ||
public get(): R|kotlin/Int| | ||
|
||
public final val letter: R|kotlin/Char| = R|<local>/letter| | ||
public get(): R|kotlin/Char| | ||
|
||
public final operator fun component1(): R|kotlin/Int| | ||
|
||
public final operator fun component2(): R|kotlin/Char| | ||
|
||
public final fun copy(number: R|kotlin/Int| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.number|, letter: R|kotlin/Char| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.letter|): R|com/javiersc/kotlin/kopy/playground/Foo| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdate|() public final infix fun <U> R|U|.update(transform: R|(U) -> U|): R|kotlin/Unit| { | ||
} | ||
|
||
public final val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionSet|() public final infix fun <S> R|S|.set(other: R|S|): R|kotlin/Unit| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionCopy|() public final infix fun copy(copy: R|com/javiersc/kotlin/kopy/playground/Foo.() -> kotlin/Unit|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdateEach|() public final infix fun <UE> R|kotlin/collections/Iterable<UE>|.updateEach(transform: R|(UE) -> UE|): R|kotlin/Unit| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionInvoke|() public final operator infix fun invoke(copy: R|com/javiersc/kotlin/kopy/playground/Foo.() -> kotlin/Unit|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
kopy-compiler/test-data/diagnostics-kopy-functions/all/all.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// OPT_IN: com.javiersc.kotlin.kopy.KopyOptIn | ||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -MISSING_DEPENDENCY_CLASS -MISSING_DEPENDENCY_SUPERCLASS | ||
|
||
package com.javiersc.kotlin.kopy.playground | ||
|
||
import com.javiersc.kotlin.kopy.Kopy | ||
|
||
@Kopy | ||
data class Foo(val number: Int, val letter: Char) |
36 changes: 36 additions & 0 deletions
36
kopy-compiler/test-data/diagnostics-kopy-functions/copy/copy.fir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FILE: copy.kt | ||
package com.javiersc.kotlin.kopy.playground | ||
|
||
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Foo : R|kotlin/Any| { | ||
public constructor(number: R|kotlin/Int|, letter: R|kotlin/Char|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
public final val number: R|kotlin/Int| = R|<local>/number| | ||
public get(): R|kotlin/Int| | ||
|
||
public final val letter: R|kotlin/Char| = R|<local>/letter| | ||
public get(): R|kotlin/Char| | ||
|
||
public final operator fun component1(): R|kotlin/Int| | ||
|
||
public final operator fun component2(): R|kotlin/Char| | ||
|
||
public final fun copy(number: R|kotlin/Int| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.number|, letter: R|kotlin/Char| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.letter|): R|com/javiersc/kotlin/kopy/playground/Foo| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdate|() public final infix fun <U> R|U|.update(transform: R|(U) -> U|): R|kotlin/Unit| { | ||
} | ||
|
||
public final val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionSet|() public final infix fun <S> R|S|.set(other: R|S|): R|kotlin/Unit| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionCopy|() public final infix fun copy(copy: R|com/javiersc/kotlin/kopy/playground/Foo.() -> kotlin/Unit|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdateEach|() public final infix fun <UE> R|kotlin/collections/Iterable<UE>|.updateEach(transform: R|(UE) -> UE|): R|kotlin/Unit| { | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
kopy-compiler/test-data/diagnostics-kopy-functions/copy/copy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// OPT_IN: com.javiersc.kotlin.kopy.KopyOptIn | ||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -MISSING_DEPENDENCY_CLASS -MISSING_DEPENDENCY_SUPERCLASS | ||
|
||
package com.javiersc.kotlin.kopy.playground | ||
|
||
import com.javiersc.kotlin.kopy.Kopy | ||
|
||
@Kopy | ||
data class Foo(val number: Int, val letter: Char) |
36 changes: 36 additions & 0 deletions
36
kopy-compiler/test-data/diagnostics-kopy-functions/invoke/invoke.fir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FILE: invoke.kt | ||
package com.javiersc.kotlin.kopy.playground | ||
|
||
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Foo : R|kotlin/Any| { | ||
public constructor(number: R|kotlin/Int|, letter: R|kotlin/Char|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
public final val number: R|kotlin/Int| = R|<local>/number| | ||
public get(): R|kotlin/Int| | ||
|
||
public final val letter: R|kotlin/Char| = R|<local>/letter| | ||
public get(): R|kotlin/Char| | ||
|
||
public final operator fun component1(): R|kotlin/Int| | ||
|
||
public final operator fun component2(): R|kotlin/Char| | ||
|
||
public final fun copy(number: R|kotlin/Int| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.number|, letter: R|kotlin/Char| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.letter|): R|com/javiersc/kotlin/kopy/playground/Foo| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdate|() public final infix fun <U> R|U|.update(transform: R|(U) -> U|): R|kotlin/Unit| { | ||
} | ||
|
||
public final val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionSet|() public final infix fun <S> R|S|.set(other: R|S|): R|kotlin/Unit| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionUpdateEach|() public final infix fun <UE> R|kotlin/collections/Iterable<UE>|.updateEach(transform: R|(UE) -> UE|): R|kotlin/Unit| { | ||
} | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionInvoke|() public final operator infix fun invoke(copy: R|com/javiersc/kotlin/kopy/playground/Foo.() -> kotlin/Unit|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
kopy-compiler/test-data/diagnostics-kopy-functions/invoke/invoke.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// OPT_IN: com.javiersc.kotlin.kopy.KopyOptIn | ||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -MISSING_DEPENDENCY_CLASS -MISSING_DEPENDENCY_SUPERCLASS | ||
|
||
package com.javiersc.kotlin.kopy.playground | ||
|
||
import com.javiersc.kotlin.kopy.Kopy | ||
|
||
@Kopy | ||
data class Foo(val number: Int, val letter: Char) |
28 changes: 28 additions & 0 deletions
28
...piler/test-gen/java/com/javiersc/kotlin/kopy/compiler/KopyAllDiagnosticTestGenerated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
|
||
package com.javiersc.kotlin.kopy.compiler; | ||
|
||
import com.intellij.testFramework.TestDataPath; | ||
import org.jetbrains.kotlin.test.util.KtTestUtil; | ||
import org.jetbrains.kotlin.test.TestMetadata; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.util.regex.Pattern; | ||
|
||
/** This class is generated by {@link com.javiersc.kotlin.kopy.compiler.GenerateKotlinCompilerTestsKt}. DO NOT MODIFY MANUALLY */ | ||
@SuppressWarnings("all") | ||
@TestMetadata("test-data/diagnostics-kopy-functions/all") | ||
@TestDataPath("$PROJECT_ROOT") | ||
public class KopyAllDiagnosticTestGenerated extends AbstractKopyAllDiagnosticTest { | ||
@Test | ||
@TestMetadata("all.kt") | ||
public void testAll() { | ||
runTest("test-data/diagnostics-kopy-functions/all/all.kt"); | ||
} | ||
|
||
@Test | ||
public void testAllFilesPresentInAll() { | ||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("test-data/diagnostics-kopy-functions/all"), Pattern.compile("^(.+)\\.kt$"), null, true); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...iler/test-gen/java/com/javiersc/kotlin/kopy/compiler/KopyCopyDiagnosticTestGenerated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
|
||
package com.javiersc.kotlin.kopy.compiler; | ||
|
||
import com.intellij.testFramework.TestDataPath; | ||
import org.jetbrains.kotlin.test.util.KtTestUtil; | ||
import org.jetbrains.kotlin.test.TestMetadata; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.util.regex.Pattern; | ||
|
||
/** This class is generated by {@link com.javiersc.kotlin.kopy.compiler.GenerateKotlinCompilerTestsKt}. DO NOT MODIFY MANUALLY */ | ||
@SuppressWarnings("all") | ||
@TestMetadata("test-data/diagnostics-kopy-functions/copy") | ||
@TestDataPath("$PROJECT_ROOT") | ||
public class KopyCopyDiagnosticTestGenerated extends AbstractKopyCopyDiagnosticTest { | ||
@Test | ||
public void testAllFilesPresentInCopy() { | ||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("test-data/diagnostics-kopy-functions/copy"), Pattern.compile("^(.+)\\.kt$"), null, true); | ||
} | ||
|
||
@Test | ||
@TestMetadata("copy.kt") | ||
public void testCopy() { | ||
runTest("test-data/diagnostics-kopy-functions/copy/copy.kt"); | ||
} | ||
} |
Oops, something went wrong.