1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-21 15:53:47 +00:00
This commit is contained in:
InsanusMokrassar 2022-08-06 00:39:46 +06:00
parent 771fb5c288
commit 8b451791dd
33 changed files with 32 additions and 43 deletions

View File

@ -28,6 +28,8 @@
* `Utils`:
* **BREAKING CHANGES** Now all new classcasts (like `Chat.ifPrivateChat` etc.) have been rewritten to be generated with `ksp` and `kotlin poet`
*Note: Versions 3.0.0 and 3.0.1 have been published with errors and didn't recommend to use*
## 2.2.2
* `Utils`:

View File

@ -12,8 +12,7 @@ pluginManagement {
}
include ":tgbotapi.core"
include ":tgbotapi.ksp:processor"
include ":tgbotapi.ksp:lib"
include ":tgbotapi.ksp"
include ":tgbotapi.api"
include ":tgbotapi.utils"
include ":tgbotapi.behaviour_builder"

View File

@ -29,8 +29,6 @@ kotlin {
api libs.microutils.languageCodes
api libs.ktor.client.core
compileOnly project(":tgbotapi.ksp:lib")
}
}
commonTest {
@ -52,8 +50,7 @@ kotlin {
}
dependencies {
add("kspCommonMainMetadata", project(":tgbotapi.ksp:processor"))
add("kspJvm", project(":tgbotapi.ksp:processor"))
add("kspJvm", project(":tgbotapi.ksp"))
}
ksp {

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
import dev.inmo.tgbotapi.types.payments.abstracts.Priced

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.chat.User
/**

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer
import kotlinx.serialization.Serializable

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.actions
import dev.inmo.micro_utils.common.Warning
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.games.CallbackGame
import dev.inmo.tgbotapi.types.webapps.WebAppInfo

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.buttons
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import kotlinx.serialization.Serializable
@Serializable(KeyboardMarkupSerializer::class)

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.chat
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.dice
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.KSerializer

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.location
import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.*

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
@ClassCastsIncluded
interface ChatEvent

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.message
import dev.inmo.tgbotapi.abstracts.FromUser
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.User

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.message.abstracts
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.RawMessage

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.content
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageIdentifier

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.textsources
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.captionLength
import dev.inmo.tgbotapi.types.textLength
import kotlinx.serialization.Serializable

View File

@ -5,7 +5,7 @@ package dev.inmo.tgbotapi.types.passport
import dev.inmo.micro_utils.crypto.MD5
import dev.inmo.micro_utils.crypto.md5
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import dev.inmo.tgbotapi.types.passport.encrypted.type

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.passport.decrypted.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.passport.credentials.EndDataCredentials
@ClassCastsIncluded

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
import dev.inmo.micro_utils.crypto.SourceBytes
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.polls
import com.soywiz.klock.DateTime
import com.soywiz.klock.TimeSpan
import dev.inmo.tgbotapi.abstracts.TextedInput
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.RawMessageEntity

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.update.abstracts
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.update.RawUpdate
import dev.inmo.tgbotapi.utils.RiskFeature

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.utils.internal
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
internal annotation class ClassCastsIncluded

View File

@ -9,5 +9,4 @@ repositories {
dependencies {
implementation libs.kotlin.poet
implementation libs.ksp
implementation project(":tgbotapi.ksp:lib")
}

View File

@ -1,7 +0,0 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
}
project.description = "Class Casts generator KSP library to include into your library"
apply from: "$mppProjectWithSerializationPresetPath"

View File

@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.ksp.lib
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class ClassCastsIncluded

View File

@ -7,7 +7,6 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.ksp.writeTo
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
import java.io.File
class TelegramBotAPISymbolProcessor(
@ -17,7 +16,7 @@ class TelegramBotAPISymbolProcessor(
private val outputFolder: String? = null
) : SymbolProcessor {
override fun process(resolver: Resolver): List<KSAnnotated> {
val classes = resolver.getSymbolsWithAnnotation(ClassCastsIncluded::class.qualifiedName!!).filterIsInstance<KSClassDeclaration>()
val classes = resolver.getSymbolsWithAnnotation("dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded").filterIsInstance<KSClassDeclaration>()
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
resolver.getAllFiles().forEach {