mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-17 22:39:25 +00:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
481130c9bb | |||
698ed6718d | |||
d164813bb4 | |||
52157ee0e7 | |||
877b62fe5d | |||
d823a02971 | |||
e950056e3b | |||
70014ba233 | |||
4425f24a20 | |||
410964a44b | |||
30389e8536 | |||
5314833041 | |||
40f7cf7678 | |||
83a0b07062 | |||
1b4900d691 | |||
f9795d53a0 | |||
2b9bb4f141 | |||
9196e4c367 | |||
374a5a1a37 | |||
827cf32c1b | |||
98ad6dbeb2 | |||
63c8f642ec |
47
CHANGELOG.md
47
CHANGELOG.md
@@ -1,5 +1,52 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.21.5
|
||||||
|
|
||||||
|
* `KSP`:
|
||||||
|
* Add utility functions `KSClassDeclaration.findSubClasses`
|
||||||
|
* `Sealed`:
|
||||||
|
* Improve generation
|
||||||
|
|
||||||
|
## 0.21.4
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Compose`:
|
||||||
|
* Add support of mingw, linux, arm64 targets
|
||||||
|
* `Coroutines`:
|
||||||
|
* `Compose`:
|
||||||
|
* Add support of mingw, linux, arm64 targets
|
||||||
|
* `Koin`:
|
||||||
|
* Add support of mingw, linux, arm64 targets
|
||||||
|
* `KSP`:
|
||||||
|
* `ClassCasts`:
|
||||||
|
* Add support of mingw, linux, arm64 targets
|
||||||
|
* `Sealed`:
|
||||||
|
* Add support of mingw, linux, arm64 targets
|
||||||
|
|
||||||
|
## 0.21.3
|
||||||
|
|
||||||
|
* `Colors`:
|
||||||
|
* Added as a module. It should be used by default in case you wish all the API currently realized for `HEXAColor`
|
||||||
|
* `Coroutines`:
|
||||||
|
* Fix of [#374](https://github.com/InsanusMokrassar/MicroUtils/issues/374):
|
||||||
|
* Add vararg variants of `awaitFirst`
|
||||||
|
* Add `joinFirst`
|
||||||
|
|
||||||
|
## 0.21.2
|
||||||
|
|
||||||
|
* `KSP`:
|
||||||
|
* `ClassCasts`:
|
||||||
|
* Module has been initialized
|
||||||
|
|
||||||
|
## 0.21.1
|
||||||
|
|
||||||
|
* `KSP`:
|
||||||
|
* Module has been initialized
|
||||||
|
* `Generator`:
|
||||||
|
* Module has been initialized
|
||||||
|
* `Sealed`:
|
||||||
|
* Module has been initialized
|
||||||
|
|
||||||
## 0.21.0
|
## 0.21.0
|
||||||
|
|
||||||
**THIS UPDATE CONTAINS BREAKING CHANGES IN `safely*`-ORIENTED FUNCTIONS**
|
**THIS UPDATE CONTAINS BREAKING CHANGES IN `safely*`-ORIENTED FUNCTIONS**
|
||||||
|
17
colors/build.gradle
Normal file
17
colors/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "com.android.library"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.colors.common")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
298
colors/src/commonMain/kotlin/StandardColors.kt
Normal file
298
colors/src/commonMain/kotlin/StandardColors.kt
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
package dev.inmo.micro_utils.colors
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.colors.common.HEXAColor
|
||||||
|
|
||||||
|
val HEXAColor.Companion.aliceblue
|
||||||
|
get() = HEXAColor(0xF0F8FFFFu)
|
||||||
|
val HEXAColor.Companion.antiquewhite
|
||||||
|
get() = HEXAColor(0xFAEBD7FFu)
|
||||||
|
val HEXAColor.Companion.aqua
|
||||||
|
get() = HEXAColor(0x00FFFFFFu)
|
||||||
|
val HEXAColor.Companion.aquamarine
|
||||||
|
get() = HEXAColor(0x7FFFD4FFu)
|
||||||
|
val HEXAColor.Companion.azure
|
||||||
|
get() = HEXAColor(0xF0FFFFFFu)
|
||||||
|
val HEXAColor.Companion.beige
|
||||||
|
get() = HEXAColor(0xF5F5DCFFu)
|
||||||
|
val HEXAColor.Companion.bisque
|
||||||
|
get() = HEXAColor(0xFFE4C4FFu)
|
||||||
|
val HEXAColor.Companion.black
|
||||||
|
get() = HEXAColor(0x000000FFu)
|
||||||
|
val HEXAColor.Companion.blanchedalmond
|
||||||
|
get() = HEXAColor(0xFFEBCDFFu)
|
||||||
|
val HEXAColor.Companion.blue
|
||||||
|
get() = HEXAColor(0x0000FFFFu)
|
||||||
|
val HEXAColor.Companion.blueviolet
|
||||||
|
get() = HEXAColor(0x8A2BE2FFu)
|
||||||
|
val HEXAColor.Companion.brown
|
||||||
|
get() = HEXAColor(0xA52A2AFFu)
|
||||||
|
val HEXAColor.Companion.burlywood
|
||||||
|
get() = HEXAColor(0xDEB887FFu)
|
||||||
|
val HEXAColor.Companion.cadetblue
|
||||||
|
get() = HEXAColor(0x5F9EA0FFu)
|
||||||
|
val HEXAColor.Companion.chartreuse
|
||||||
|
get() = HEXAColor(0x7FFF00FFu)
|
||||||
|
val HEXAColor.Companion.chocolate
|
||||||
|
get() = HEXAColor(0xD2691EFFu)
|
||||||
|
val HEXAColor.Companion.coral
|
||||||
|
get() = HEXAColor(0xFF7F50FFu)
|
||||||
|
val HEXAColor.Companion.cornflowerblue
|
||||||
|
get() = HEXAColor(0x6495EDFFu)
|
||||||
|
val HEXAColor.Companion.cornsilk
|
||||||
|
get() = HEXAColor(0xFFF8DCFFu)
|
||||||
|
val HEXAColor.Companion.crimson
|
||||||
|
get() = HEXAColor(0xDC143CFFu)
|
||||||
|
val HEXAColor.Companion.cyan
|
||||||
|
get() = HEXAColor(0x00FFFFFFu)
|
||||||
|
val HEXAColor.Companion.darkblue
|
||||||
|
get() = HEXAColor(0x00008BFFu)
|
||||||
|
val HEXAColor.Companion.darkcyan
|
||||||
|
get() = HEXAColor(0x008B8BFFu)
|
||||||
|
val HEXAColor.Companion.darkgoldenrod
|
||||||
|
get() = HEXAColor(0xB8860BFFu)
|
||||||
|
val HEXAColor.Companion.darkgray
|
||||||
|
get() = HEXAColor(0xA9A9A9FFu)
|
||||||
|
val HEXAColor.Companion.darkgreen
|
||||||
|
get() = HEXAColor(0x006400FFu)
|
||||||
|
val HEXAColor.Companion.darkgrey
|
||||||
|
get() = HEXAColor(0xA9A9A9FFu)
|
||||||
|
val HEXAColor.Companion.darkkhaki
|
||||||
|
get() = HEXAColor(0xBDB76BFFu)
|
||||||
|
val HEXAColor.Companion.darkmagenta
|
||||||
|
get() = HEXAColor(0x8B008BFFu)
|
||||||
|
val HEXAColor.Companion.darkolivegreen
|
||||||
|
get() = HEXAColor(0x556B2FFFu)
|
||||||
|
val HEXAColor.Companion.darkorange
|
||||||
|
get() = HEXAColor(0xFF8C00FFu)
|
||||||
|
val HEXAColor.Companion.darkorchid
|
||||||
|
get() = HEXAColor(0x9932CCFFu)
|
||||||
|
val HEXAColor.Companion.darkred
|
||||||
|
get() = HEXAColor(0x8B0000FFu)
|
||||||
|
val HEXAColor.Companion.darksalmon
|
||||||
|
get() = HEXAColor(0xE9967AFFu)
|
||||||
|
val HEXAColor.Companion.darkseagreen
|
||||||
|
get() = HEXAColor(0x8FBC8FFFu)
|
||||||
|
val HEXAColor.Companion.darkslateblue
|
||||||
|
get() = HEXAColor(0x483D8BFFu)
|
||||||
|
val HEXAColor.Companion.darkslategray
|
||||||
|
get() = HEXAColor(0x2F4F4FFFu)
|
||||||
|
val HEXAColor.Companion.darkslategrey
|
||||||
|
get() = HEXAColor(0x2F4F4FFFu)
|
||||||
|
val HEXAColor.Companion.darkturquoise
|
||||||
|
get() = HEXAColor(0x00CED1FFu)
|
||||||
|
val HEXAColor.Companion.darkviolet
|
||||||
|
get() = HEXAColor(0x9400D3FFu)
|
||||||
|
val HEXAColor.Companion.deeppink
|
||||||
|
get() = HEXAColor(0xFF1493FFu)
|
||||||
|
val HEXAColor.Companion.deepskyblue
|
||||||
|
get() = HEXAColor(0x00BFFFFFu)
|
||||||
|
val HEXAColor.Companion.dimgray
|
||||||
|
get() = HEXAColor(0x696969FFu)
|
||||||
|
val HEXAColor.Companion.dimgrey
|
||||||
|
get() = HEXAColor(0x696969FFu)
|
||||||
|
val HEXAColor.Companion.dodgerblue
|
||||||
|
get() = HEXAColor(0x1E90FFFFu)
|
||||||
|
val HEXAColor.Companion.firebrick
|
||||||
|
get() = HEXAColor(0xB22222FFu)
|
||||||
|
val HEXAColor.Companion.floralwhite
|
||||||
|
get() = HEXAColor(0xFFFAF0FFu)
|
||||||
|
val HEXAColor.Companion.forestgreen
|
||||||
|
get() = HEXAColor(0x228B22FFu)
|
||||||
|
val HEXAColor.Companion.fuchsia
|
||||||
|
get() = HEXAColor(0xFF00FFFFu)
|
||||||
|
val HEXAColor.Companion.gainsboro
|
||||||
|
get() = HEXAColor(0xDCDCDCFFu)
|
||||||
|
val HEXAColor.Companion.ghostwhite
|
||||||
|
get() = HEXAColor(0xF8F8FFFFu)
|
||||||
|
val HEXAColor.Companion.gold
|
||||||
|
get() = HEXAColor(0xFFD700FFu)
|
||||||
|
val HEXAColor.Companion.goldenrod
|
||||||
|
get() = HEXAColor(0xDAA520FFu)
|
||||||
|
val HEXAColor.Companion.gray
|
||||||
|
get() = HEXAColor(0x808080FFu)
|
||||||
|
val HEXAColor.Companion.green
|
||||||
|
get() = HEXAColor(0x008000FFu)
|
||||||
|
val HEXAColor.Companion.greenyellow
|
||||||
|
get() = HEXAColor(0xADFF2FFFu)
|
||||||
|
val HEXAColor.Companion.grey
|
||||||
|
get() = HEXAColor(0x808080FFu)
|
||||||
|
val HEXAColor.Companion.honeydew
|
||||||
|
get() = HEXAColor(0xF0FFF0FFu)
|
||||||
|
val HEXAColor.Companion.hotpink
|
||||||
|
get() = HEXAColor(0xFF69B4FFu)
|
||||||
|
val HEXAColor.Companion.indianred
|
||||||
|
get() = HEXAColor(0xCD5C5CFFu)
|
||||||
|
val HEXAColor.Companion.indigo
|
||||||
|
get() = HEXAColor(0x4B0082FFu)
|
||||||
|
val HEXAColor.Companion.ivory
|
||||||
|
get() = HEXAColor(0xFFFFF0FFu)
|
||||||
|
val HEXAColor.Companion.khaki
|
||||||
|
get() = HEXAColor(0xF0E68CFFu)
|
||||||
|
val HEXAColor.Companion.lavender
|
||||||
|
get() = HEXAColor(0xE6E6FAFFu)
|
||||||
|
val HEXAColor.Companion.lavenderblush
|
||||||
|
get() = HEXAColor(0xFFF0F5FFu)
|
||||||
|
val HEXAColor.Companion.lawngreen
|
||||||
|
get() = HEXAColor(0x7CFC00FFu)
|
||||||
|
val HEXAColor.Companion.lemonchiffon
|
||||||
|
get() = HEXAColor(0xFFFACDFFu)
|
||||||
|
val HEXAColor.Companion.lightblue
|
||||||
|
get() = HEXAColor(0xADD8E6FFu)
|
||||||
|
val HEXAColor.Companion.lightcoral
|
||||||
|
get() = HEXAColor(0xF08080FFu)
|
||||||
|
val HEXAColor.Companion.lightcyan
|
||||||
|
get() = HEXAColor(0xE0FFFFFFu)
|
||||||
|
val HEXAColor.Companion.lightgoldenrodyellow
|
||||||
|
get() = HEXAColor(0xFAFAD2FFu)
|
||||||
|
val HEXAColor.Companion.lightgray
|
||||||
|
get() = HEXAColor(0xD3D3D3FFu)
|
||||||
|
val HEXAColor.Companion.lightgreen
|
||||||
|
get() = HEXAColor(0x90EE90FFu)
|
||||||
|
val HEXAColor.Companion.lightgrey
|
||||||
|
get() = HEXAColor(0xD3D3D3FFu)
|
||||||
|
val HEXAColor.Companion.lightpink
|
||||||
|
get() = HEXAColor(0xFFB6C1FFu)
|
||||||
|
val HEXAColor.Companion.lightsalmon
|
||||||
|
get() = HEXAColor(0xFFA07AFFu)
|
||||||
|
val HEXAColor.Companion.lightseagreen
|
||||||
|
get() = HEXAColor(0x20B2AAFFu)
|
||||||
|
val HEXAColor.Companion.lightskyblue
|
||||||
|
get() = HEXAColor(0x87CEFAFFu)
|
||||||
|
val HEXAColor.Companion.lightslategray
|
||||||
|
get() = HEXAColor(0x778899FFu)
|
||||||
|
val HEXAColor.Companion.lightslategrey
|
||||||
|
get() = HEXAColor(0x778899FFu)
|
||||||
|
val HEXAColor.Companion.lightsteelblue
|
||||||
|
get() = HEXAColor(0xB0C4DEFFu)
|
||||||
|
val HEXAColor.Companion.lightyellow
|
||||||
|
get() = HEXAColor(0xFFFFE0FFu)
|
||||||
|
val HEXAColor.Companion.lime
|
||||||
|
get() = HEXAColor(0x00FF00FFu)
|
||||||
|
val HEXAColor.Companion.limegreen
|
||||||
|
get() = HEXAColor(0x32CD32FFu)
|
||||||
|
val HEXAColor.Companion.linen
|
||||||
|
get() = HEXAColor(0xFAF0E6FFu)
|
||||||
|
val HEXAColor.Companion.magenta
|
||||||
|
get() = HEXAColor(0xFF00FFFFu)
|
||||||
|
val HEXAColor.Companion.maroon
|
||||||
|
get() = HEXAColor(0x800000FFu)
|
||||||
|
val HEXAColor.Companion.mediumaquamarine
|
||||||
|
get() = HEXAColor(0x66CDAAFFu)
|
||||||
|
val HEXAColor.Companion.mediumblue
|
||||||
|
get() = HEXAColor(0x0000CDFFu)
|
||||||
|
val HEXAColor.Companion.mediumorchid
|
||||||
|
get() = HEXAColor(0xBA55D3FFu)
|
||||||
|
val HEXAColor.Companion.mediumpurple
|
||||||
|
get() = HEXAColor(0x9370DBFFu)
|
||||||
|
val HEXAColor.Companion.mediumseagreen
|
||||||
|
get() = HEXAColor(0x3CB371FFu)
|
||||||
|
val HEXAColor.Companion.mediumslateblue
|
||||||
|
get() = HEXAColor(0x7B68EEFFu)
|
||||||
|
val HEXAColor.Companion.mediumspringgreen
|
||||||
|
get() = HEXAColor(0x00FA9AFFu)
|
||||||
|
val HEXAColor.Companion.mediumturquoise
|
||||||
|
get() = HEXAColor(0x48D1CCFFu)
|
||||||
|
val HEXAColor.Companion.mediumvioletred
|
||||||
|
get() = HEXAColor(0xC71585FFu)
|
||||||
|
val HEXAColor.Companion.midnightblue
|
||||||
|
get() = HEXAColor(0x191970FFu)
|
||||||
|
val HEXAColor.Companion.mintcream
|
||||||
|
get() = HEXAColor(0xF5FFFAFFu)
|
||||||
|
val HEXAColor.Companion.mistyrose
|
||||||
|
get() = HEXAColor(0xFFE4E1FFu)
|
||||||
|
val HEXAColor.Companion.moccasin
|
||||||
|
get() = HEXAColor(0xFFE4B5FFu)
|
||||||
|
val HEXAColor.Companion.navajowhite
|
||||||
|
get() = HEXAColor(0xFFDEADFFu)
|
||||||
|
val HEXAColor.Companion.navy
|
||||||
|
get() = HEXAColor(0x000080FFu)
|
||||||
|
val HEXAColor.Companion.oldlace
|
||||||
|
get() = HEXAColor(0xFDF5E6FFu)
|
||||||
|
val HEXAColor.Companion.olive
|
||||||
|
get() = HEXAColor(0x808000FFu)
|
||||||
|
val HEXAColor.Companion.olivedrab
|
||||||
|
get() = HEXAColor(0x6B8E23FFu)
|
||||||
|
val HEXAColor.Companion.orange
|
||||||
|
get() = HEXAColor(0xFFA500FFu)
|
||||||
|
val HEXAColor.Companion.orangered
|
||||||
|
get() = HEXAColor(0xFF4500FFu)
|
||||||
|
val HEXAColor.Companion.orchid
|
||||||
|
get() = HEXAColor(0xDA70D6FFu)
|
||||||
|
val HEXAColor.Companion.palegoldenrod
|
||||||
|
get() = HEXAColor(0xEEE8AAFFu)
|
||||||
|
val HEXAColor.Companion.palegreen
|
||||||
|
get() = HEXAColor(0x98FB98FFu)
|
||||||
|
val HEXAColor.Companion.paleturquoise
|
||||||
|
get() = HEXAColor(0xAFEEEEFFu)
|
||||||
|
val HEXAColor.Companion.palevioletred
|
||||||
|
get() = HEXAColor(0xDB7093FFu)
|
||||||
|
val HEXAColor.Companion.papayawhip
|
||||||
|
get() = HEXAColor(0xFFEFD5FFu)
|
||||||
|
val HEXAColor.Companion.peachpuff
|
||||||
|
get() = HEXAColor(0xFFDAB9FFu)
|
||||||
|
val HEXAColor.Companion.peru
|
||||||
|
get() = HEXAColor(0xCD853FFFu)
|
||||||
|
val HEXAColor.Companion.pink
|
||||||
|
get() = HEXAColor(0xFFC0CBFFu)
|
||||||
|
val HEXAColor.Companion.plum
|
||||||
|
get() = HEXAColor(0xDDA0DDFFu)
|
||||||
|
val HEXAColor.Companion.powderblue
|
||||||
|
get() = HEXAColor(0xB0E0E6FFu)
|
||||||
|
val HEXAColor.Companion.purple
|
||||||
|
get() = HEXAColor(0x800080FFu)
|
||||||
|
val HEXAColor.Companion.red
|
||||||
|
get() = HEXAColor(0xFF0000FFu)
|
||||||
|
val HEXAColor.Companion.rosybrown
|
||||||
|
get() = HEXAColor(0xBC8F8FFFu)
|
||||||
|
val HEXAColor.Companion.royalblue
|
||||||
|
get() = HEXAColor(0x4169E1FFu)
|
||||||
|
val HEXAColor.Companion.saddlebrown
|
||||||
|
get() = HEXAColor(0x8B4513FFu)
|
||||||
|
val HEXAColor.Companion.salmon
|
||||||
|
get() = HEXAColor(0xFA8072FFu)
|
||||||
|
val HEXAColor.Companion.sandybrown
|
||||||
|
get() = HEXAColor(0xF4A460FFu)
|
||||||
|
val HEXAColor.Companion.seagreen
|
||||||
|
get() = HEXAColor(0x2E8B57FFu)
|
||||||
|
val HEXAColor.Companion.seashell
|
||||||
|
get() = HEXAColor(0xFFF5EEFFu)
|
||||||
|
val HEXAColor.Companion.sienna
|
||||||
|
get() = HEXAColor(0xA0522DFFu)
|
||||||
|
val HEXAColor.Companion.silver
|
||||||
|
get() = HEXAColor(0xC0C0C0FFu)
|
||||||
|
val HEXAColor.Companion.skyblue
|
||||||
|
get() = HEXAColor(0x87CEEBFFu)
|
||||||
|
val HEXAColor.Companion.slateblue
|
||||||
|
get() = HEXAColor(0x6A5ACDFFu)
|
||||||
|
val HEXAColor.Companion.slategray
|
||||||
|
get() = HEXAColor(0x708090FFu)
|
||||||
|
val HEXAColor.Companion.slategrey
|
||||||
|
get() = HEXAColor(0x708090FFu)
|
||||||
|
val HEXAColor.Companion.snow
|
||||||
|
get() = HEXAColor(0xFFFAFAFFu)
|
||||||
|
val HEXAColor.Companion.springgreen
|
||||||
|
get() = HEXAColor(0x00FF7FFFu)
|
||||||
|
val HEXAColor.Companion.steelblue
|
||||||
|
get() = HEXAColor(0x4682B4FFu)
|
||||||
|
val HEXAColor.Companion.tan
|
||||||
|
get() = HEXAColor(0xD2B48CFFu)
|
||||||
|
val HEXAColor.Companion.teal
|
||||||
|
get() = HEXAColor(0x008080FFu)
|
||||||
|
val HEXAColor.Companion.thistle
|
||||||
|
get() = HEXAColor(0xD8BFD8FFu)
|
||||||
|
val HEXAColor.Companion.tomato
|
||||||
|
get() = HEXAColor(0xFF6347FFu)
|
||||||
|
val HEXAColor.Companion.turquoise
|
||||||
|
get() = HEXAColor(0x40E0D0FFu)
|
||||||
|
val HEXAColor.Companion.violet
|
||||||
|
get() = HEXAColor(0xEE82EEFFu)
|
||||||
|
val HEXAColor.Companion.wheat
|
||||||
|
get() = HEXAColor(0xF5DEB3FFu)
|
||||||
|
val HEXAColor.Companion.white
|
||||||
|
get() = HEXAColor(0xFFFFFFFFu)
|
||||||
|
val HEXAColor.Companion.whitesmoke
|
||||||
|
get() = HEXAColor(0xF5F5F5FFu)
|
||||||
|
val HEXAColor.Companion.yellow
|
||||||
|
get() = HEXAColor(0xFFFF00FFu)
|
||||||
|
val HEXAColor.Companion.yellowgreen
|
||||||
|
get() = HEXAColor(0x9ACD32FFu)
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
alias(libs.plugins.jb.compose)
|
alias(libs.plugins.jb.compose)
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppProjectWithSerializationAndComposePresetPath"
|
apply from: "$mppComposeJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
alias(libs.plugins.jb.compose)
|
alias(libs.plugins.jb.compose)
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppProjectWithSerializationAndComposePresetPath"
|
apply from: "$mppComposeJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@@ -3,6 +3,12 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Deferred.await] on all [this] [Deferred]s. The first [Deferred] completed its work will interrupt all
|
||||||
|
* others awaits and, if [cancelOnResult] passed as true (**by default**), will also cancel all the others [Deferred]s
|
||||||
|
*
|
||||||
|
* @param scope Will be used to create [CoroutineScope.LinkedSupervisorScope] and launch joining of all [Job]s in it
|
||||||
|
*/
|
||||||
suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(
|
suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
cancelOnResult: Boolean = true
|
cancelOnResult: Boolean = true
|
||||||
@@ -24,10 +30,45 @@ suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Deferred.await] on all [this] [Deferred]s. The first [Deferred] completed its work will interrupt all
|
||||||
|
* others awaits and, if [cancelOnResult] passed as true (**by default**), will also cancel all the others [Deferred]s
|
||||||
|
*
|
||||||
|
* @param scope Will be used to create [CoroutineScope.LinkedSupervisorScope] and launch joining of all [Job]s in it
|
||||||
|
*/
|
||||||
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(
|
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
cancelOnResult: Boolean = true
|
cancelOnResult: Boolean = true
|
||||||
): T = awaitFirstWithDeferred(scope, cancelOnResult).second
|
): T = awaitFirstWithDeferred(scope, cancelOnResult).second
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Deferred.await] on all [this] [Deferred]s. The first [Deferred] completed its work will interrupt all
|
||||||
|
* others awaits and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [Deferred]s
|
||||||
|
*
|
||||||
|
* Creates [CoroutineScope] using [coroutineContext] for internal purposes
|
||||||
|
*/
|
||||||
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(
|
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(
|
||||||
cancelOthers: Boolean = true
|
cancelOthers: Boolean = true
|
||||||
): T = awaitFirst(CoroutineScope(coroutineContext), cancelOthers)
|
): T = awaitFirst(CoroutineScope(coroutineContext), cancelOthers)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Deferred.await] on all [deferreds]. The first [Deferred] completed its work will interrupt all
|
||||||
|
* others awaits and, if [cancelOnResult] passed as true (**by default**), will also cancel all the others [deferreds]
|
||||||
|
*
|
||||||
|
* @param scope Will be used to create [CoroutineScope.LinkedSupervisorScope] and launch joining of all [Job]s in it
|
||||||
|
*/
|
||||||
|
suspend fun <T> awaitFirst(
|
||||||
|
vararg deferreds: Deferred<T>,
|
||||||
|
scope: CoroutineScope,
|
||||||
|
cancelOnResult: Boolean = true
|
||||||
|
): T = deferreds.toList().awaitFirstWithDeferred(scope, cancelOnResult).second
|
||||||
|
/**
|
||||||
|
* Trying to [Deferred.await] on all [deferreds]. The first [Deferred] completed its work will interrupt all
|
||||||
|
* others awaits and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [deferreds]
|
||||||
|
*
|
||||||
|
* Creates [CoroutineScope] using [coroutineContext] for internal purposes
|
||||||
|
*/
|
||||||
|
suspend fun <T> awaitFirst(
|
||||||
|
vararg deferreds: Deferred<T>,
|
||||||
|
cancelOthers: Boolean = true
|
||||||
|
): T = awaitFirst(*deferreds, scope = CoroutineScope(coroutineContext), cancelOnResult = cancelOthers)
|
||||||
|
@@ -0,0 +1,64 @@
|
|||||||
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Job.join] on all [this] [Job]s. The first [Job] completed its work will interrupt all others joins
|
||||||
|
* and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [Job]s
|
||||||
|
*
|
||||||
|
* @param scope Will be used to create [CoroutineScope.LinkedSupervisorScope] and launch joining of all [Job]s in it
|
||||||
|
*/
|
||||||
|
suspend fun Iterable<Job>.joinFirst(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
cancelOthers: Boolean = true
|
||||||
|
): Job {
|
||||||
|
val resultDeferred = CompletableDeferred<Job>()
|
||||||
|
val scope = scope.LinkedSupervisorScope()
|
||||||
|
forEach {
|
||||||
|
scope.launch {
|
||||||
|
it.join()
|
||||||
|
resultDeferred.complete(it)
|
||||||
|
scope.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultDeferred.await().also {
|
||||||
|
if (cancelOthers) {
|
||||||
|
forEach {
|
||||||
|
runCatchingSafely { it.cancel() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Trying to [Job.join] on all [this] [Job]s. The first [Job] completed its work will interrupt all others joins
|
||||||
|
* and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [Job]s
|
||||||
|
*
|
||||||
|
* Creates [CoroutineScope] using [coroutineContext] for internal purposes
|
||||||
|
*/
|
||||||
|
suspend fun Iterable<Job>.joinFirst(
|
||||||
|
cancelOthers: Boolean = true
|
||||||
|
): Job = joinFirst(CoroutineScope(coroutineContext), cancelOthers)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Job.join] on all [jobs]. The first [Job] completed its work will interrupt all others joins
|
||||||
|
* and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [Job]s
|
||||||
|
*
|
||||||
|
* @param scope Will be used to create [CoroutineScope.LinkedSupervisorScope] and launch joining of all [Job]s in it
|
||||||
|
*/
|
||||||
|
suspend fun joinFirst(
|
||||||
|
vararg jobs: Job,
|
||||||
|
scope: CoroutineScope,
|
||||||
|
cancelOthers: Boolean = true
|
||||||
|
): Job = jobs.toList().joinFirst(scope, cancelOthers)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trying to [Job.join] on all [jobs]. The first [Job] completed its work will interrupt all others joins
|
||||||
|
* and, if [cancelOthers] passed as true (**by default**), will also cancel all the others [Job]s
|
||||||
|
*
|
||||||
|
* Creates [CoroutineScope] using [coroutineContext] for internal purposes
|
||||||
|
*/
|
||||||
|
suspend fun joinFirst(
|
||||||
|
vararg jobs: Job,
|
||||||
|
cancelOthers: Boolean = true
|
||||||
|
): Job = joinFirst(*jobs, scope = CoroutineScope(coroutineContext), cancelOthers = cancelOthers)
|
@@ -32,6 +32,7 @@ allprojects {
|
|||||||
mppJvmJsLinuxMingwProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsLinuxMingwProject.gradle"
|
mppJvmJsLinuxMingwProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsLinuxMingwProject.gradle"
|
||||||
mppJvmJsLinuxMingwLinuxArm64ProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsLinuxMingwLinuxArm64Project.gradle"
|
mppJvmJsLinuxMingwLinuxArm64ProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsLinuxMingwLinuxArm64Project.gradle"
|
||||||
mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsAndroidLinuxMingwLinuxArm64Project.gradle"
|
mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsAndroidLinuxMingwLinuxArm64Project.gradle"
|
||||||
|
mppComposeJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppComposeJvmJsAndroidLinuxMingwLinuxArm64Project.gradle"
|
||||||
mppAndroidProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppAndroidProject.gradle"
|
mppAndroidProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppAndroidProject.gradle"
|
||||||
|
|
||||||
defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle"
|
defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle"
|
||||||
|
@@ -15,5 +15,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.21.0
|
version=0.21.5
|
||||||
android_code_version=259
|
android_code_version=264
|
||||||
|
@@ -4,7 +4,7 @@ plugins {
|
|||||||
id "com.android.library"
|
id "com.android.library"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppProjectWithSerializationPresetPath"
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
id "com.google.devtools.ksp"
|
id "com.google.devtools.ksp"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppProjectWithSerializationPresetPath"
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
7
ksp/classcasts/build.gradle
Normal file
7
ksp/classcasts/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "com.android.library"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
21
ksp/classcasts/generator/build.gradle
Normal file
21
ksp/classcasts/generator/build.gradle
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.jvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$publishJvmOnlyPath"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.ksp.generator")
|
||||||
|
api project(":micro_utils.ksp.classcasts")
|
||||||
|
api libs.kotlin.poet
|
||||||
|
api libs.ksp
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
90
ksp/classcasts/generator/src/main/kotlin/ClassCastsFiller.kt
Normal file
90
ksp/classcasts/generator/src/main/kotlin/ClassCastsFiller.kt
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.symbol.ClassKind
|
||||||
|
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||||
|
import com.squareup.kotlinpoet.*
|
||||||
|
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
|
||||||
|
import com.squareup.kotlinpoet.ksp.toClassName
|
||||||
|
import com.squareup.kotlinpoet.ksp.toTypeName
|
||||||
|
|
||||||
|
|
||||||
|
private fun FileSpec.Builder.addTopLevelImport(className: ClassName) {
|
||||||
|
className.topLevelClassName().let {
|
||||||
|
addImport(it.packageName, it.simpleNames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FileSpec.Builder.createTypeDefinition(ksClassDeclaration: KSClassDeclaration): TypeName {
|
||||||
|
val className = ksClassDeclaration.toClassName()
|
||||||
|
return if (ksClassDeclaration.typeParameters.isNotEmpty()) {
|
||||||
|
className.parameterizedBy(
|
||||||
|
ksClassDeclaration.typeParameters.map {
|
||||||
|
it.bounds.first().resolve().also {
|
||||||
|
val typeClassName = it.toClassName()
|
||||||
|
addTopLevelImport(typeClassName)
|
||||||
|
}.toTypeName()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
className
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun FileSpec.Builder.fill(
|
||||||
|
sourceKSClassDeclaration: KSClassDeclaration,
|
||||||
|
subtypes: Set<KSClassDeclaration>
|
||||||
|
) {
|
||||||
|
subtypes.forEach { targetClassDeclaration ->
|
||||||
|
val sourceClassName = sourceKSClassDeclaration.toClassName()
|
||||||
|
val targetClassClassName = targetClassDeclaration.toClassName()
|
||||||
|
val targetClassTypeDefinition = createTypeDefinition(targetClassDeclaration)
|
||||||
|
val simpleName = targetClassDeclaration.simpleName.asString()
|
||||||
|
val withFirstLowerCase = simpleName.replaceFirstChar { it.lowercase() }
|
||||||
|
val castedOrNullName = "${withFirstLowerCase}OrNull"
|
||||||
|
|
||||||
|
addTopLevelImport(targetClassClassName)
|
||||||
|
addFunction(
|
||||||
|
FunSpec.builder(castedOrNullName).apply {
|
||||||
|
receiver(sourceClassName)
|
||||||
|
addCode(
|
||||||
|
"return this as? %L",
|
||||||
|
targetClassTypeDefinition
|
||||||
|
)
|
||||||
|
returns(targetClassTypeDefinition.copy(nullable = true))
|
||||||
|
addModifiers(KModifier.INLINE)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
addFunction(
|
||||||
|
FunSpec.builder("${withFirstLowerCase}OrThrow").apply {
|
||||||
|
receiver(sourceClassName)
|
||||||
|
addCode(
|
||||||
|
"return this as %L",
|
||||||
|
targetClassTypeDefinition
|
||||||
|
)
|
||||||
|
returns(targetClassTypeDefinition)
|
||||||
|
addModifiers(KModifier.INLINE)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
addFunction(
|
||||||
|
FunSpec.builder("if$simpleName").apply {
|
||||||
|
val genericType = TypeVariableName("T", null)
|
||||||
|
addTypeVariable(genericType)
|
||||||
|
receiver(sourceClassName)
|
||||||
|
addParameter(
|
||||||
|
"block",
|
||||||
|
LambdaTypeName.get(
|
||||||
|
null,
|
||||||
|
targetClassTypeDefinition,
|
||||||
|
returnType = genericType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
addCode(
|
||||||
|
"return ${castedOrNullName}() ?.let(block)",
|
||||||
|
targetClassTypeDefinition
|
||||||
|
)
|
||||||
|
returns(genericType.copy(nullable = true))
|
||||||
|
addModifiers(KModifier.INLINE)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
119
ksp/classcasts/generator/src/main/kotlin/Processor.kt
Normal file
119
ksp/classcasts/generator/src/main/kotlin/Processor.kt
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.KspExperimental
|
||||||
|
import com.google.devtools.ksp.getAllSuperTypes
|
||||||
|
import com.google.devtools.ksp.getAnnotationsByType
|
||||||
|
import com.google.devtools.ksp.isAnnotationPresent
|
||||||
|
import com.google.devtools.ksp.processing.CodeGenerator
|
||||||
|
import com.google.devtools.ksp.processing.Resolver
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||||
|
import com.google.devtools.ksp.symbol.*
|
||||||
|
import com.squareup.kotlinpoet.*
|
||||||
|
import com.squareup.kotlinpoet.ksp.toClassName
|
||||||
|
import dev.inmo.micro_ksp.generator.writeFile
|
||||||
|
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsExcluded
|
||||||
|
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsIncluded
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class Processor(
|
||||||
|
private val codeGenerator: CodeGenerator
|
||||||
|
) : SymbolProcessor {
|
||||||
|
@OptIn(KspExperimental::class)
|
||||||
|
private fun FileSpec.Builder.generateClassCasts(
|
||||||
|
ksClassDeclaration: KSClassDeclaration,
|
||||||
|
resolver: Resolver
|
||||||
|
) {
|
||||||
|
val rootAnnotation = ksClassDeclaration.getAnnotationsByType(ClassCastsIncluded::class).first()
|
||||||
|
val (includeRegex: Regex?, excludeRegex: Regex?) = rootAnnotation.let {
|
||||||
|
it.typesRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) to it.excludeRegex.takeIf { it.isNotEmpty() } ?.let(::Regex)
|
||||||
|
}
|
||||||
|
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
|
||||||
|
|
||||||
|
fun KSClassDeclaration.checkSupertypeLevel(levelsAllowed: Int?): Boolean {
|
||||||
|
val supertypes by lazy {
|
||||||
|
superTypes.map { it.resolve().declaration }
|
||||||
|
}
|
||||||
|
return when {
|
||||||
|
levelsAllowed == null -> true
|
||||||
|
levelsAllowed <= 0 -> false
|
||||||
|
supertypes.any { it == ksClassDeclaration } -> true
|
||||||
|
else -> supertypes.any {
|
||||||
|
(it as? KSClassDeclaration) ?.checkSupertypeLevel(levelsAllowed - 1) == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun handleDeclaration(ksDeclarationContainer: KSDeclarationContainer) {
|
||||||
|
ksDeclarationContainer.declarations.forEach { potentialSubtype ->
|
||||||
|
val simpleName = potentialSubtype.simpleName.getShortName()
|
||||||
|
when {
|
||||||
|
potentialSubtype === ksClassDeclaration -> {}
|
||||||
|
potentialSubtype.isAnnotationPresent(ClassCastsExcluded::class) -> return@forEach
|
||||||
|
potentialSubtype !is KSClassDeclaration || !potentialSubtype.checkSupertypeLevel(rootAnnotation.levelsToInclude.takeIf { it >= 0 }) -> return@forEach
|
||||||
|
excludeRegex ?.matches(simpleName) == true -> return@forEach
|
||||||
|
includeRegex ?.matches(simpleName) == false -> {}
|
||||||
|
else -> classesSubtypes.getOrPut(ksClassDeclaration) { mutableSetOf() }.add(potentialSubtype)
|
||||||
|
}
|
||||||
|
handleDeclaration(potentialSubtype as? KSDeclarationContainer ?: return@forEach)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolver.getAllFiles().forEach {
|
||||||
|
handleDeclaration(it)
|
||||||
|
}
|
||||||
|
fun fillWithSealeds(current: KSClassDeclaration) {
|
||||||
|
current.getSealedSubclasses().forEach {
|
||||||
|
val simpleName = it.simpleName.getShortName()
|
||||||
|
if (
|
||||||
|
includeRegex ?.matches(simpleName) == false
|
||||||
|
|| excludeRegex ?.matches(simpleName) == true
|
||||||
|
|| it.isAnnotationPresent(ClassCastsExcluded::class)
|
||||||
|
) {
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
classesSubtypes.getOrPut(ksClassDeclaration) { mutableSetOf() }.add(it)
|
||||||
|
fillWithSealeds(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fillWithSealeds(ksClassDeclaration)
|
||||||
|
|
||||||
|
addAnnotation(
|
||||||
|
AnnotationSpec.builder(Suppress::class).apply {
|
||||||
|
addMember("\"unused\"")
|
||||||
|
addMember("\"RemoveRedundantQualifierName\"")
|
||||||
|
addMember("\"RedundantVisibilityModifier\"")
|
||||||
|
addMember("\"NOTHING_TO_INLINE\"")
|
||||||
|
addMember("\"UNCHECKED_CAST\"")
|
||||||
|
addMember("\"OPT_IN_USAGE\"")
|
||||||
|
useSiteTarget(AnnotationSpec.UseSiteTarget.FILE)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
fill(
|
||||||
|
ksClassDeclaration,
|
||||||
|
classesSubtypes.values.flatten().toSet()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(KspExperimental::class)
|
||||||
|
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||||
|
(resolver.getSymbolsWithAnnotation(ClassCastsIncluded::class.qualifiedName!!)).filterIsInstance<KSClassDeclaration>().forEach {
|
||||||
|
val prefix = it.getAnnotationsByType(ClassCastsIncluded::class).first().outputFilePrefix
|
||||||
|
it.writeFile(prefix = prefix, suffix = "ClassCasts") {
|
||||||
|
FileSpec.builder(
|
||||||
|
it.packageName.asString(),
|
||||||
|
"${it.simpleName.getShortName()}ClassCasts"
|
||||||
|
).apply {
|
||||||
|
addFileComment(
|
||||||
|
"""
|
||||||
|
THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||||
|
TO REGENERATE IT JUST DELETE FILE
|
||||||
|
ORIGINAL FILE: ${it.containingFile ?.fileName}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
generateClassCasts(it, resolver)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
}
|
11
ksp/classcasts/generator/src/main/kotlin/Provider.kt
Normal file
11
ksp/classcasts/generator/src/main/kotlin/Provider.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
||||||
|
|
||||||
|
class Provider : SymbolProcessorProvider {
|
||||||
|
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor = Processor(
|
||||||
|
environment.codeGenerator
|
||||||
|
)
|
||||||
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.Provider
|
27
ksp/classcasts/generator/test/build.gradle
Normal file
27
ksp/classcasts/generator/test/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "com.android.library"
|
||||||
|
id "com.google.devtools.ksp"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.ksp.classcasts")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
add("kspCommonMainMetadata", project(":micro_utils.ksp.classcasts.generator"))
|
||||||
|
}
|
||||||
|
|
||||||
|
ksp {
|
||||||
|
}
|
15
ksp/classcasts/generator/test/src/commonMain/kotlin/Test.kt
Normal file
15
ksp/classcasts/generator/test/src/commonMain/kotlin/Test.kt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts.generator.test
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsExcluded
|
||||||
|
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsIncluded
|
||||||
|
|
||||||
|
@ClassCastsIncluded(levelsToInclude = 1)
|
||||||
|
sealed interface Test {
|
||||||
|
object A : Test
|
||||||
|
@ClassCastsExcluded
|
||||||
|
object B : Test // Will not be included in class casts due to annotation ClassCastsExcluded
|
||||||
|
object C : Test
|
||||||
|
interface D : Test {
|
||||||
|
object DD : D // Will not be included in class casts due to levelsToInclude
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,40 @@
|
|||||||
|
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||||
|
// TO REGENERATE IT JUST DELETE FILE
|
||||||
|
// ORIGINAL FILE: Test.kt
|
||||||
|
@file:Suppress(
|
||||||
|
"unused",
|
||||||
|
"RemoveRedundantQualifierName",
|
||||||
|
"RedundantVisibilityModifier",
|
||||||
|
"NOTHING_TO_INLINE",
|
||||||
|
"UNCHECKED_CAST",
|
||||||
|
"OPT_IN_USAGE",
|
||||||
|
)
|
||||||
|
|
||||||
|
package dev.inmo.micro_utils.ksp.classcasts.generator.test
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.ksp.classcasts.generator.test.Test
|
||||||
|
import kotlin.Suppress
|
||||||
|
|
||||||
|
public inline fun Test.aOrNull(): Test.A? = this as?
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.A
|
||||||
|
|
||||||
|
public inline fun Test.aOrThrow(): Test.A = this as
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.A
|
||||||
|
|
||||||
|
public inline fun <T> Test.ifA(block: (Test.A) -> T): T? = aOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun Test.cOrNull(): Test.C? = this as?
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.C
|
||||||
|
|
||||||
|
public inline fun Test.cOrThrow(): Test.C = this as
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.C
|
||||||
|
|
||||||
|
public inline fun <T> Test.ifC(block: (Test.C) -> T): T? = cOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun Test.dOrNull(): Test.D? = this as?
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.D
|
||||||
|
|
||||||
|
public inline fun Test.dOrThrow(): Test.D = this as
|
||||||
|
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.D
|
||||||
|
|
||||||
|
public inline fun <T> Test.ifD(block: (Test.D) -> T): T? = dOrNull() ?.let(block)
|
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
annotation class ClassCastsExcluded
|
10
ksp/classcasts/src/commonMain/kotlin/ClassCastsIncluded.kt
Normal file
10
ksp/classcasts/src/commonMain/kotlin/ClassCastsIncluded.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.classcasts
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
annotation class ClassCastsIncluded(
|
||||||
|
val typesRegex: String = "",
|
||||||
|
val excludeRegex: String = "",
|
||||||
|
val outputFilePrefix: String = "",
|
||||||
|
val levelsToInclude: Int = -1
|
||||||
|
)
|
20
ksp/generator/build.gradle
Normal file
20
ksp/generator/build.gradle
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.jvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$publishJvmOnlyPath"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.common")
|
||||||
|
api libs.kotlin.poet
|
||||||
|
api libs.ksp
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
49
ksp/generator/src/main/kotlin/FilesWorkaround.kt
Normal file
49
ksp/generator/src/main/kotlin/FilesWorkaround.kt
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package dev.inmo.micro_ksp.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||||
|
import com.google.devtools.ksp.symbol.KSFile
|
||||||
|
import com.squareup.kotlinpoet.FileSpec
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
fun KSClassDeclaration.writeFile(
|
||||||
|
prefix: String = "",
|
||||||
|
suffix: String = "",
|
||||||
|
relatedPath: String = "",
|
||||||
|
force: Boolean = false,
|
||||||
|
fileSpecBuilder: () -> FileSpec
|
||||||
|
) {
|
||||||
|
val containingFile = containingFile!!
|
||||||
|
File(
|
||||||
|
File(
|
||||||
|
File(containingFile.filePath).parent,
|
||||||
|
relatedPath
|
||||||
|
),
|
||||||
|
"$prefix${simpleName.asString()}$suffix.kt"
|
||||||
|
).takeIf { force || !it.exists() } ?.apply {
|
||||||
|
parentFile.mkdirs()
|
||||||
|
writer().use { writer ->
|
||||||
|
fileSpecBuilder().writeTo(writer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KSFile.writeFile(
|
||||||
|
prefix: String = "",
|
||||||
|
suffix: String = "",
|
||||||
|
relatedPath: String = "",
|
||||||
|
force: Boolean = false,
|
||||||
|
fileSpecBuilder: () -> FileSpec
|
||||||
|
) {
|
||||||
|
File(
|
||||||
|
File(
|
||||||
|
File(filePath).parent,
|
||||||
|
relatedPath
|
||||||
|
),
|
||||||
|
"$prefix${fileName.dropLastWhile { it != '.' }.removeSuffix(".")}$suffix.kt"
|
||||||
|
).takeIf { force || !it.exists() } ?.apply {
|
||||||
|
parentFile.mkdirs()
|
||||||
|
writer().use { writer ->
|
||||||
|
fileSpecBuilder().writeTo(writer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
ksp/generator/src/main/kotlin/WalkOnKSFiles.kt
Normal file
30
ksp/generator/src/main/kotlin/WalkOnKSFiles.kt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package dev.inmo.micro_ksp.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.getAllSuperTypes
|
||||||
|
import com.google.devtools.ksp.symbol.KSAnnotated
|
||||||
|
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||||
|
import com.google.devtools.ksp.symbol.KSDeclarationContainer
|
||||||
|
import com.google.devtools.ksp.symbol.KSFile
|
||||||
|
|
||||||
|
fun KSClassDeclaration.findSubClasses(subSymbol: KSAnnotated): Sequence<KSClassDeclaration> {
|
||||||
|
return when (subSymbol) {
|
||||||
|
is KSClassDeclaration -> if (subSymbol.getAllSuperTypes().map { it.declaration }.contains(this)) {
|
||||||
|
sequenceOf(subSymbol)
|
||||||
|
} else {
|
||||||
|
sequenceOf()
|
||||||
|
}
|
||||||
|
else -> sequenceOf()
|
||||||
|
} + if (subSymbol is KSDeclarationContainer) {
|
||||||
|
subSymbol.declarations.flatMap {
|
||||||
|
findSubClasses(it)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sequenceOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KSClassDeclaration.findSubClasses(files: Sequence<KSAnnotated>): Sequence<KSClassDeclaration> {
|
||||||
|
return files.flatMap {
|
||||||
|
findSubClasses(it)
|
||||||
|
}
|
||||||
|
}
|
7
ksp/sealed/build.gradle
Normal file
7
ksp/sealed/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "com.android.library"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
21
ksp/sealed/generator/build.gradle
Normal file
21
ksp/sealed/generator/build.gradle
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.jvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$publishJvmOnlyPath"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.ksp.generator")
|
||||||
|
api project(":micro_utils.ksp.sealed")
|
||||||
|
api libs.kotlin.poet
|
||||||
|
api libs.ksp
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
129
ksp/sealed/generator/src/main/kotlin/Processor.kt
Normal file
129
ksp/sealed/generator/src/main/kotlin/Processor.kt
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.sealed.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.KspExperimental
|
||||||
|
import com.google.devtools.ksp.getAnnotationsByType
|
||||||
|
import com.google.devtools.ksp.processing.CodeGenerator
|
||||||
|
import com.google.devtools.ksp.processing.Resolver
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||||
|
import com.google.devtools.ksp.symbol.*
|
||||||
|
import com.squareup.kotlinpoet.ClassName
|
||||||
|
import com.squareup.kotlinpoet.CodeBlock
|
||||||
|
import com.squareup.kotlinpoet.FileSpec
|
||||||
|
import com.squareup.kotlinpoet.FunSpec
|
||||||
|
import com.squareup.kotlinpoet.KModifier
|
||||||
|
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
|
||||||
|
import com.squareup.kotlinpoet.PropertySpec
|
||||||
|
import com.squareup.kotlinpoet.asTypeName
|
||||||
|
import com.squareup.kotlinpoet.ksp.toClassName
|
||||||
|
import dev.inmo.micro_ksp.generator.findSubClasses
|
||||||
|
import dev.inmo.micro_ksp.generator.writeFile
|
||||||
|
import dev.inmo.microutils.kps.sealed.GenerateSealedWorkaround
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class Processor(
|
||||||
|
private val codeGenerator: CodeGenerator
|
||||||
|
) : SymbolProcessor {
|
||||||
|
private fun KSClassDeclaration.findSealedConnection(potentialSealedParent: KSClassDeclaration): Boolean {
|
||||||
|
val targetClassname = potentialSealedParent.qualifiedName ?.asString()
|
||||||
|
return superTypes.any {
|
||||||
|
targetClassname == ((it.resolve().declaration as? KSClassDeclaration) ?.qualifiedName ?.asString()) || (it is KSClassDeclaration && it.getSealedSubclasses().any() && it.findSealedConnection(potentialSealedParent))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun KSClassDeclaration.resolveSubclasses(
|
||||||
|
searchIn: Sequence<KSAnnotated>,
|
||||||
|
allowNonSealed: Boolean
|
||||||
|
): Sequence<KSClassDeclaration> {
|
||||||
|
return findSubClasses(searchIn).let {
|
||||||
|
if (allowNonSealed) {
|
||||||
|
it
|
||||||
|
} else {
|
||||||
|
it.filter {
|
||||||
|
it.findSealedConnection(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(KspExperimental::class)
|
||||||
|
private fun FileSpec.Builder.generateSealedWorkaround(
|
||||||
|
ksClassDeclaration: KSClassDeclaration,
|
||||||
|
resolver: Resolver
|
||||||
|
) {
|
||||||
|
val annotation = ksClassDeclaration.getAnnotationsByType(GenerateSealedWorkaround::class).first()
|
||||||
|
val subClasses = ksClassDeclaration.resolveSubclasses(
|
||||||
|
searchIn = resolver.getAllFiles(),
|
||||||
|
allowNonSealed = annotation.includeNonSealedSubTypes
|
||||||
|
).distinct()
|
||||||
|
val subClassesNames = subClasses.filter {
|
||||||
|
when (it.classKind) {
|
||||||
|
ClassKind.ENUM_ENTRY,
|
||||||
|
ClassKind.OBJECT -> true
|
||||||
|
ClassKind.INTERFACE,
|
||||||
|
ClassKind.CLASS,
|
||||||
|
ClassKind.ENUM_CLASS,
|
||||||
|
ClassKind.ANNOTATION_CLASS -> false
|
||||||
|
}
|
||||||
|
}.filter {
|
||||||
|
it.getAnnotationsByType(GenerateSealedWorkaround.Exclude::class).count() == 0
|
||||||
|
}.sortedBy {
|
||||||
|
(it.getAnnotationsByType(GenerateSealedWorkaround.Order::class).firstOrNull()) ?.order ?: 0
|
||||||
|
}.map {
|
||||||
|
it.toClassName()
|
||||||
|
}.toList()
|
||||||
|
val className = ksClassDeclaration.toClassName()
|
||||||
|
val setType = Set::class.asTypeName().parameterizedBy(
|
||||||
|
ksClassDeclaration.toClassName()
|
||||||
|
)
|
||||||
|
addProperty(
|
||||||
|
PropertySpec.builder(
|
||||||
|
"values",
|
||||||
|
setType
|
||||||
|
).apply {
|
||||||
|
modifiers.add(
|
||||||
|
KModifier.PRIVATE
|
||||||
|
)
|
||||||
|
initializer(
|
||||||
|
CodeBlock.of(
|
||||||
|
"""setOf(${subClassesNames.joinToString(",\n") {it.simpleNames.joinToString(".")}})"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
addFunction(
|
||||||
|
FunSpec.builder("values").apply {
|
||||||
|
receiver(ClassName(className.packageName, *className.simpleNames.toTypedArray(), "Companion"))
|
||||||
|
returns(setType)
|
||||||
|
addCode(
|
||||||
|
CodeBlock.of(
|
||||||
|
"""return values"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(KspExperimental::class)
|
||||||
|
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||||
|
(resolver.getSymbolsWithAnnotation(GenerateSealedWorkaround::class.qualifiedName!!)).filterIsInstance<KSClassDeclaration>().forEach {
|
||||||
|
val prefix = it.getAnnotationsByType(GenerateSealedWorkaround::class).first().prefix
|
||||||
|
it.writeFile(prefix = prefix, suffix = "SealedWorkaround") {
|
||||||
|
FileSpec.builder(
|
||||||
|
it.packageName.asString(),
|
||||||
|
"${it.simpleName.getShortName()}SealedWorkaround"
|
||||||
|
).apply {
|
||||||
|
addFileComment(
|
||||||
|
"""
|
||||||
|
THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||||
|
TO REGENERATE IT JUST DELETE FILE
|
||||||
|
ORIGINAL FILE: ${it.containingFile ?.fileName}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
generateSealedWorkaround(it, resolver)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
}
|
11
ksp/sealed/generator/src/main/kotlin/Provider.kt
Normal file
11
ksp/sealed/generator/src/main/kotlin/Provider.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.sealed.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
||||||
|
|
||||||
|
class Provider : SymbolProcessorProvider {
|
||||||
|
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor = Processor(
|
||||||
|
environment.codeGenerator
|
||||||
|
)
|
||||||
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
dev.inmo.micro_utils.ksp.sealed.generator.Provider
|
27
ksp/sealed/generator/test/build.gradle
Normal file
27
ksp/sealed/generator/test/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "com.android.library"
|
||||||
|
id "com.google.devtools.ksp"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api project(":micro_utils.ksp.sealed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
add("kspCommonMainMetadata", project(":micro_utils.ksp.sealed.generator"))
|
||||||
|
}
|
||||||
|
|
||||||
|
ksp {
|
||||||
|
}
|
16
ksp/sealed/generator/test/src/commonMain/kotlin/Test.kt
Normal file
16
ksp/sealed/generator/test/src/commonMain/kotlin/Test.kt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.sealed.generator.test
|
||||||
|
|
||||||
|
import dev.inmo.microutils.kps.sealed.GenerateSealedWorkaround
|
||||||
|
|
||||||
|
@GenerateSealedWorkaround
|
||||||
|
sealed interface Test {
|
||||||
|
@GenerateSealedWorkaround.Order(2)
|
||||||
|
object A : Test
|
||||||
|
@GenerateSealedWorkaround.Exclude
|
||||||
|
object B : Test
|
||||||
|
@GenerateSealedWorkaround.Order(0)
|
||||||
|
object C : Test
|
||||||
|
|
||||||
|
// Required for successful sealed workaround generation
|
||||||
|
companion object
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||||
|
// TO REGENERATE IT JUST DELETE FILE
|
||||||
|
// ORIGINAL FILE: Test.kt
|
||||||
|
package dev.inmo.micro_utils.ksp.`sealed`.generator.test
|
||||||
|
|
||||||
|
import kotlin.collections.Set
|
||||||
|
|
||||||
|
private val values: Set<Test> = setOf(Test.C,
|
||||||
|
Test.A)
|
||||||
|
|
||||||
|
public fun Test.Companion.values(): Set<Test> = values
|
15
ksp/sealed/src/commonMain/kotlin/GenerateSealedWorkaround.kt
Normal file
15
ksp/sealed/src/commonMain/kotlin/GenerateSealedWorkaround.kt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.microutils.kps.sealed
|
||||||
|
|
||||||
|
@Retention(AnnotationRetention.BINARY)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
annotation class GenerateSealedWorkaround(
|
||||||
|
val prefix: String = "",
|
||||||
|
val includeNonSealedSubTypes: Boolean = false
|
||||||
|
) {
|
||||||
|
@Retention(AnnotationRetention.BINARY)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
annotation class Order(val order: Int)
|
||||||
|
@Retention(AnnotationRetention.BINARY)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
annotation class Exclude
|
||||||
|
}
|
97
mppComposeJvmJsAndroidLinuxMingwLinuxArm64Project.gradle
Normal file
97
mppComposeJvmJsAndroidLinuxMingwLinuxArm64Project.gradle
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
project.version = "$version"
|
||||||
|
project.group = "$group"
|
||||||
|
|
||||||
|
apply from: "$publishGradlePath"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm {
|
||||||
|
compilations.main {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
js (IR) {
|
||||||
|
browser()
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
|
androidTarget {
|
||||||
|
publishAllLibraryVariants()
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
linuxX64()
|
||||||
|
mingwX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('stdlib')
|
||||||
|
implementation compose.runtime
|
||||||
|
api libs.kt.serialization
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commonTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-common')
|
||||||
|
implementation kotlin('test-annotations-common')
|
||||||
|
implementation libs.kt.coroutines.test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
androidUnitTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-junit')
|
||||||
|
implementation libs.android.test.junit
|
||||||
|
implementation libs.android.espresso
|
||||||
|
implementation compose.uiTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
androidInstrumentedTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-junit')
|
||||||
|
implementation libs.android.test.junit
|
||||||
|
implementation libs.android.espresso
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
implementation compose.desktop.currentOs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvmTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-junit')
|
||||||
|
implementation compose.uiTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
implementation compose.web.core
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-js')
|
||||||
|
implementation kotlin('test-junit')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nativeMain.dependsOn commonMain
|
||||||
|
linuxX64Main.dependsOn nativeMain
|
||||||
|
mingwX64Main.dependsOn nativeMain
|
||||||
|
linuxArm64Main.dependsOn nativeMain
|
||||||
|
|
||||||
|
androidMain.dependsOn jvmMain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$defaultAndroidSettingsPresetPath"
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
@@ -42,6 +42,8 @@ String[] includes = [
|
|||||||
":serialization:mapper",
|
":serialization:mapper",
|
||||||
":startup:plugin",
|
":startup:plugin",
|
||||||
":startup:launcher",
|
":startup:launcher",
|
||||||
|
|
||||||
|
":colors",
|
||||||
":colors:common",
|
":colors:common",
|
||||||
|
|
||||||
":resources",
|
":resources",
|
||||||
@@ -49,6 +51,16 @@ String[] includes = [
|
|||||||
":fsm:common",
|
":fsm:common",
|
||||||
":fsm:repos:common",
|
":fsm:repos:common",
|
||||||
|
|
||||||
|
":ksp:generator",
|
||||||
|
|
||||||
|
":ksp:sealed",
|
||||||
|
":ksp:sealed:generator",
|
||||||
|
":ksp:sealed:generator:test",
|
||||||
|
|
||||||
|
":ksp:classcasts",
|
||||||
|
":ksp:classcasts:generator",
|
||||||
|
":ksp:classcasts:generator:test",
|
||||||
|
|
||||||
":dokka"
|
":dokka"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user