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
KopyVisibility
to set the visibility of the generated functions
- Loading branch information
1 parent
7570011
commit 9a3951c
Showing
73 changed files
with
2,453 additions
and
25 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
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
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,30 @@ | ||
hubdle { | ||
config { | ||
analysis() | ||
coverage() | ||
documentation { // | ||
api() | ||
} | ||
explicitApi() | ||
format.isEnabled = false | ||
publishing { | ||
maven { | ||
repositories { // | ||
mavenLocalTest() | ||
} | ||
} | ||
} | ||
} | ||
kotlin { | ||
multiplatform { | ||
common { | ||
main { | ||
dependencies { // | ||
implementation(hubdle.jetbrains.kotlinx.atomicfu) | ||
} | ||
} | ||
} | ||
jvm() | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
kopy-args/common/main/kotlin/com/javiersc/kotlin/kopy/args/KopyVisibility.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,36 @@ | ||
package com.javiersc.kotlin.kopy.args | ||
|
||
import java.io.Serializable | ||
|
||
public enum class KopyVisibility( | ||
public val value: String, | ||
public val restrictive: Int, | ||
) : Serializable { | ||
Auto(value = "auto", restrictive = 0), | ||
Public(value = "public", restrictive = 1), | ||
Internal(value = "internal", restrictive = 2), | ||
Protected(value = "protected", restrictive = 3), | ||
Private(value = "private", restrictive = 4), | ||
; | ||
|
||
public companion object { | ||
|
||
public const val NAME: String = "KopyVisibility" | ||
public const val DESCRIPTION: String = "Visibility of the generated copy function" | ||
|
||
public fun from(value: String): KopyVisibility = | ||
when (value) { | ||
Auto.name -> Auto | ||
Auto.value -> Auto | ||
Public.name -> Public | ||
Public.value -> Public | ||
Internal.name -> Internal | ||
Internal.value -> Internal | ||
Protected.name -> Protected | ||
Protected.value -> Protected | ||
Private.name -> Private | ||
Private.value -> Private | ||
else -> Auto | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
kopy-args/common/test/kotlin/com/javiersc/kotlin/kopy/args/KopyVisibilityTest.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,22 @@ | ||
package com.javiersc.kotlin.kopy.args | ||
|
||
import io.kotest.matchers.shouldBe | ||
import kotlin.test.Test | ||
|
||
class KopyVisibilityTest { | ||
|
||
@Test | ||
fun `kopy visibility`() { | ||
KopyVisibility.from("auto") shouldBe KopyVisibility.Auto | ||
KopyVisibility.from("Auto") shouldBe KopyVisibility.Auto | ||
KopyVisibility.from("public") shouldBe KopyVisibility.Public | ||
KopyVisibility.from("Public") shouldBe KopyVisibility.Public | ||
KopyVisibility.from("internal") shouldBe KopyVisibility.Internal | ||
KopyVisibility.from("Internal") shouldBe KopyVisibility.Internal | ||
KopyVisibility.from("protected") shouldBe KopyVisibility.Protected | ||
KopyVisibility.from("Protected") shouldBe KopyVisibility.Protected | ||
KopyVisibility.from("private") shouldBe KopyVisibility.Private | ||
KopyVisibility.from("Private") shouldBe KopyVisibility.Private | ||
KopyVisibility.from("random") shouldBe KopyVisibility.Auto | ||
} | ||
} |
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
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
8 changes: 8 additions & 0 deletions
8
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.javiersc.kotlin.kopy.compiler | ||
|
||
import com.javiersc.kotlin.kopy.args.KopyVisibility | ||
import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
|
||
internal object KopyKey { | ||
val Visibility = CompilerConfigurationKey<KopyVisibility>(KopyVisibility.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
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
46 changes: 46 additions & 0 deletions
46
kopy-compiler/test-data/diagnostics-kopy-visibility/0_auto/internal.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,46 @@ | ||
FILE: internal.kt | ||
package com.javiersc.kotlin.kopy.playground | ||
|
||
public final fun diagnostics(): R|kotlin/Unit| { | ||
lval foo1: R|com/javiersc/kotlin/kopy/playground/Foo| = R|com/javiersc/kotlin/kopy/playground/Foo.Foo|(Int(7), Char(W)) | ||
lval foo21: R|com/javiersc/kotlin/kopy/playground/Foo| = R|<local>/foo1|.R|com/javiersc/kotlin/kopy/playground/Foo.copy|(copy@fun R|com/javiersc/kotlin/kopy/playground/Foo|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> { | ||
(this@R|special/anonymous|, this@R|special/anonymous|.R|com/javiersc/kotlin/kopy/playground/Foo.number|).R|com/javiersc/kotlin/kopy/playground/Foo.set|<R|kotlin/Int|>(Int(42)) | ||
} | ||
) | ||
} | ||
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Foo : R|kotlin/Any| { | ||
internal 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|() internal final infix fun <U> R|U|.update(transform: R|(U) -> U|): R|kotlin/Unit| { | ||
} | ||
|
||
internal final val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
internal get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>| | ||
|
||
@R|com/javiersc/kotlin/kopy/KopyOptIn|() @R|com/javiersc/kotlin/kopy/KopyFunctionSet|() internal 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|() internal 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|() internal 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|() internal final operator infix fun invoke(copy: R|com/javiersc/kotlin/kopy/playground/Foo.() -> kotlin/Unit|): R|com/javiersc/kotlin/kopy/playground/Foo| { | ||
} | ||
|
||
} |
Oops, something went wrong.