-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99783f2
commit 5c28255
Showing
9 changed files
with
122 additions
and
120 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.inmo.micro_ksp.generator | ||
|
||
import com.google.devtools.ksp.KSTypeNotPresentException | ||
import com.google.devtools.ksp.KSTypesNotPresentException | ||
import com.google.devtools.ksp.KspExperimental | ||
import com.google.devtools.ksp.symbol.KSType | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.ksp.toClassName | ||
import kotlin.reflect.KClass | ||
|
||
@OptIn(KspExperimental::class) | ||
inline fun convertToClassName(getter: () -> KClass<*>) = try { | ||
getter().asClassName() | ||
} catch (e: KSTypeNotPresentException) { | ||
e.ksType.toClassName() | ||
} | ||
|
||
@OptIn(KspExperimental::class) | ||
inline fun convertToClassNames(getter: () -> List<KClass<*>>) = try { | ||
getter().map { it.asClassName() } | ||
} catch (e: KSTypesNotPresentException) { | ||
e.ksTypes.map { | ||
it.toClassName() | ||
} | ||
} |
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
37 changes: 28 additions & 9 deletions
37
ksp/variations/generator/test/src/commonMain/kotlin/SampleFun.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
34 changes: 18 additions & 16 deletions
34
ksp/variations/generator/test/src/commonMain/kotlin/sample2GeneratedVariation.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,47 +1,49 @@ | ||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY | ||
// TO REGENERATE IT JUST DELETE FILE | ||
// ORIGINAL FILE: SampleFun.kt | ||
package dev.inmo.micro_utils.ksp.variations.generator.test | ||
|
||
import kotlin.Boolean | ||
import kotlin.Int | ||
import kotlin.String | ||
import kotlin.Unit | ||
|
||
public suspend fun Sample.sample2(arg12: Int): Unit = sample2( | ||
arg1 = arg12.toString() | ||
public suspend fun SimpleType.sample2(arg12: Int): Unit = sample2( | ||
arg1 = with(arg12) {toString()} | ||
) | ||
|
||
public suspend fun Sample.sample2(arg12: Int, arg2: Int): Unit = sample2( | ||
arg1 = arg12.toString(), arg2 = arg2 | ||
public suspend fun SimpleType.sample2(arg12: Int, arg2: Int): Unit = sample2( | ||
arg1 = with(arg12) {toString()}, arg2 = arg2 | ||
) | ||
|
||
public suspend fun Sample.sample2(arg12: Int, arg3: Boolean): Unit = sample2( | ||
arg1 = arg12.toString(), arg3 = arg3 | ||
public suspend fun SimpleType.sample2(arg12: Int, arg3: Boolean): Unit = sample2( | ||
arg1 = with(arg12) {toString()}, arg3 = arg3 | ||
) | ||
|
||
public suspend fun Sample.sample2( | ||
public suspend fun SimpleType.sample2( | ||
arg12: Int, | ||
arg2: Int, | ||
arg3: Boolean, | ||
): Unit = sample2( | ||
arg1 = arg12.toString(), arg2 = arg2, arg3 = arg3 | ||
arg1 = with(arg12) {toString()}, arg2 = arg2, arg3 = arg3 | ||
) | ||
|
||
public suspend fun Sample.sample2(arg22: String): Unit = sample2( | ||
arg2 = arg22.toInt() | ||
public suspend fun SimpleType.sample2(arg22: String): Unit = sample2( | ||
arg2 = with(arg22) {toInt()} | ||
) | ||
|
||
public suspend fun Sample.sample2(arg1: String, arg22: String): Unit = sample2( | ||
arg1 = arg1, arg2 = arg22.toInt() | ||
public suspend fun SimpleType.sample2(arg1: String, arg22: String): Unit = sample2( | ||
arg1 = arg1, arg2 = with(arg22) {toInt()} | ||
) | ||
|
||
public suspend fun Sample.sample2(arg22: String, arg3: Boolean): Unit = sample2( | ||
arg2 = arg22.toInt(), arg3 = arg3 | ||
public suspend fun SimpleType.sample2(arg22: String, arg3: Boolean): Unit = sample2( | ||
arg2 = with(arg22) {toInt()}, arg3 = arg3 | ||
) | ||
|
||
public suspend fun Sample.sample2( | ||
public suspend fun SimpleType.sample2( | ||
arg1: String, | ||
arg22: String, | ||
arg3: Boolean, | ||
): Unit = sample2( | ||
arg1 = arg1, arg2 = arg22.toInt(), arg3 = arg3 | ||
arg1 = arg1, arg2 = with(arg22) {toInt()}, arg3 = arg3 | ||
) |
11 changes: 9 additions & 2 deletions
11
ksp/variations/generator/test/src/commonMain/kotlin/sampleGeneratedVariation.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,15 @@ | ||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY | ||
// TO REGENERATE IT JUST DELETE FILE | ||
// ORIGINAL FILE: SampleFun.kt | ||
package dev.inmo.micro_utils.ksp.variations.generator.test | ||
|
||
import kotlin.Int | ||
import kotlin.Unit | ||
|
||
public fun sample(example: Sample): Unit = sample( | ||
example = example.value | ||
public fun sample(example: SimpleType): Unit = sample( | ||
example = with(example) {value} | ||
) | ||
|
||
public fun sample(example: GenericType<Int>): Unit = sample( | ||
example = with(example) {value.toString()} | ||
) |
10 changes: 10 additions & 0 deletions
10
ksp/variations/generator/test/src/commonMain/kotlin/sampleVarargGeneratedVariation.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,10 @@ | ||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY | ||
// TO REGENERATE IT JUST DELETE FILE | ||
// ORIGINAL FILE: SampleFun.kt | ||
package dev.inmo.micro_utils.ksp.variations.generator.test | ||
|
||
import kotlin.Unit | ||
|
||
public fun sampleVararg(vararg example: SimpleType): Unit = sampleVararg( | ||
example = with(example) {map { it.value }.toTypedArray()} | ||
) |
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