mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-11-17 01:03:00 +00:00
Compare commits
56
Commits
v37.0.0
...
klassindex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f4fa1e447 | ||
|
|
25cf660791 | ||
|
|
bf9268a30f | ||
|
|
ccf89830bd | ||
|
|
3932dc622b | ||
|
|
aed93a4c91 | ||
|
|
b7f8e0217f | ||
|
|
7680845578 | ||
|
|
3d8e509bde | ||
|
|
c027244fbd | ||
|
|
2be342a769 | ||
|
|
7414a9b41b | ||
|
|
8afa8bb927 | ||
|
|
27fa081163 | ||
|
|
a19b3d26df | ||
|
|
f93d9938de | ||
|
|
2531f3779e | ||
|
|
3c8e5e61f2 | ||
|
|
b882ae3ac3 | ||
|
|
00aed5779c | ||
|
|
4f5319dd51 | ||
|
|
b795a6d0a9 | ||
|
|
cb688a7831 | ||
|
|
c66d1e8665 | ||
|
|
3c5abac669 | ||
|
|
80200d78ef | ||
|
|
8cd3f91e9e | ||
|
|
2065faf157 | ||
|
|
62bc788c52 | ||
|
|
6d0686135c | ||
|
|
2a77912d44 | ||
|
|
21fa971f8a | ||
|
|
e5be5d1200 | ||
|
|
55a2cee205 | ||
|
|
7920d3d9d0 | ||
|
|
b34ab63c77 | ||
|
|
7995ec434c | ||
|
|
6ddf1e4d3f | ||
|
|
468e883910 | ||
|
|
0660aa0c33 | ||
|
|
c6f33983ef | ||
|
|
90a4b180e3 | ||
|
|
a58d6a96cb | ||
|
|
52bc5a1409 | ||
|
|
941705fb8b | ||
|
|
f13b7c217a | ||
|
|
39911466a2 | ||
|
|
82e9b3272b | ||
|
|
7cc97c12e6 | ||
|
|
865bee0068 | ||
|
|
d3ca4774da | ||
|
|
8fa5b09de9 | ||
|
|
0c1c7d1aa7 | ||
|
|
0e9f1d2202 | ||
|
|
82d38c5cb0 | ||
|
|
ce1d15ebb2 |
No files matched your search
+7
-5
@@ -18,12 +18,14 @@ plugins {
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||
}
|
||||
|
||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||
allprojects {
|
||||
if (it != rootProject.findProject("docs")) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||
task.enabled = false
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
if (it != rootProject.findProject("docs")) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
if (task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||
task.enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -77,17 +77,17 @@ Object callback = {
|
||||
}
|
||||
}
|
||||
|
||||
named("commonMain") {
|
||||
sourceRoots.setFrom(findSourcesWithName("commonMain"))
|
||||
}
|
||||
|
||||
named("jsMain") {
|
||||
sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
||||
}
|
||||
|
||||
named("jvmMain") {
|
||||
sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
||||
}
|
||||
// named("commonMain") {
|
||||
// sourceRoots.setFrom(findSourcesWithName("commonMain"))
|
||||
// }
|
||||
//
|
||||
// named("jsMain") {
|
||||
// sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
||||
// }
|
||||
//
|
||||
// named("jvmMain") {
|
||||
// sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ buildscript {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -14,6 +15,7 @@ buildscript {
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.kotlin.kapt"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
@@ -54,6 +56,7 @@ kotlin {
|
||||
api "dev.inmo:micro_utils.language_codes:$micro_utils_version"
|
||||
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api "com.github.matfax.klassindex:library:4.+"
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
@@ -95,3 +98,35 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
kapt "com.github.matfax.klassindex:processor:4.+"
|
||||
}
|
||||
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg(
|
||||
"com.github.matfax.klassindex.IndexSubclasses",
|
||||
// "dev.inmo.tgbotapi.types.update.abstracts.Update",
|
||||
// "dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent",
|
||||
// "dev.inmo.tgbotapi.types.passport.decrypted.abstracts.SecureValue",
|
||||
// "dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent",
|
||||
"dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode",
|
||||
// "dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement",
|
||||
// "dev.inmo.tgbotapi.types.passport.PassportElementError",
|
||||
// "dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery",
|
||||
// "dev.inmo.tgbotapi.types.buttons.KeyboardMarkup",
|
||||
// "dev.inmo.tgbotapi.types.actions.BotAction",
|
||||
// "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton",
|
||||
// "dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember",
|
||||
// "dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile",
|
||||
// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery",
|
||||
// "dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult",
|
||||
// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent",
|
||||
// "dev.inmo.tgbotapi.types.InputMedia.InputMedia",
|
||||
// "dev.inmo.tgbotapi.types.polls.Poll",
|
||||
// "dev.inmo.tgbotapi.types.update.abstracts.Update"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import com.github.matfax.klassindex.KlassIndex
|
||||
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
|
||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMedia
|
||||
import dev.inmo.tgbotapi.types.actions.BotAction
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent
|
||||
import dev.inmo.tgbotapi.types.passport.PassportElementError
|
||||
import dev.inmo.tgbotapi.types.passport.decrypted.abstracts.SecureValue
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun printlnInstanceSubclassesFuns(kclass: KClass<*>) {
|
||||
KlassIndex.getSubclasses(Message::class).forEach { subclass ->
|
||||
println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}")
|
||||
}
|
||||
}
|
||||
|
||||
fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set<KClass<*>>): List<Pair<String, String>> {
|
||||
return subclasses.map { subclass ->
|
||||
val typeUpperBounds = subclass.typeParameters.map { it.upperBounds.first() }
|
||||
val imports = "import ${subclass.qualifiedName}" + if (typeUpperBounds.isEmpty()) "" else typeUpperBounds.joinToString("\nimport ", "\nimport ")
|
||||
val subtype = "${subclass.simpleName}${if (typeUpperBounds.isEmpty()) "" else "<${typeUpperBounds.joinToString() { (it.classifier as KClass<*>).simpleName!! }}>"}"
|
||||
val code = "@PreviewFeature\ninline fun ${kclass.simpleName}.as${subclass.simpleName}(): $subtype? = this as? $subtype\n" +
|
||||
"@PreviewFeature\ninline fun ${kclass.simpleName}.require${subclass.simpleName}(): $subtype = this as $subtype\n" +
|
||||
"@PreviewFeature\ninline fun <T> ${kclass.simpleName}.when${subclass.simpleName}(block: (${subclass.simpleName}) -> T): $subtype = as${subclass.simpleName}() ?.let(block)"
|
||||
imports to code
|
||||
}
|
||||
}
|
||||
|
||||
val result = mutableMapOf<KClass<*>, Set<KClass<*>>>()
|
||||
|
||||
|
||||
fun main() {
|
||||
result[Message::class] = KlassIndex.getSubclasses(dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode::class).toSet()
|
||||
println("import dev.inmo.tgbotapi.utils.PreviewFeature")
|
||||
val importsToFuns = result.keys.flatMap {
|
||||
println("import ${it.qualifiedName}")
|
||||
printlnInstancesSubclassesFuns(it, result.getValue(it))
|
||||
}
|
||||
importsToFuns.forEach { println(it.first) }
|
||||
println()
|
||||
importsToFuns.forEach { println(it.second) }
|
||||
// printlnInstanceSubclassesFuns(Message::class)
|
||||
// printlnInstanceSubclassesFuns(Chat::class)
|
||||
// printlnInstanceSubclassesFuns(CallbackQuery::class)
|
||||
// printlnInstanceSubclassesFuns(KeyboardMarkup::class)
|
||||
// printlnInstanceSubclassesFuns(BotAction::class)
|
||||
// printlnInstanceSubclassesFuns(InlineKeyboardButton::class)
|
||||
// printlnInstanceSubclassesFuns(ChatMember::class)
|
||||
// printlnInstanceSubclassesFuns(TelegramMediaFile::class)
|
||||
// printlnInstanceSubclassesFuns(InlineQuery::class)
|
||||
// printlnInstanceSubclassesFuns(InlineQueryResult::class)
|
||||
// printlnInstanceSubclassesFuns(InputMessageContent::class)
|
||||
// printlnInstanceSubclassesFuns(InputMedia::class)
|
||||
// printlnInstanceSubclassesFuns(Poll::class)
|
||||
// printlnInstanceSubclassesFuns(Update::class)
|
||||
}
|
||||
Reference in new issue
Block a user