diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 300001e68..2c8156128 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,13 +7,19 @@ on: - '.github/workflows/**' workflow_dispatch: inputs: - version: - description: 'Version of library that is being documented' + build_id: + description: 'Id of TeamCity build that produced the Dokka artifact.' + required: true + dry_run: + type: boolean + description: "Dry run. If set to true, the action will not actually publish the pages, but will assemble the artifact." + default: true required: true permissions: id-token: write pages: write + contents: read env: INSTANCE: 'kotlinx-rpc/rpc' @@ -90,10 +96,23 @@ jobs: run: unzip -O UTF-8 -qq '${{ env.ARTIFACT }}' -d ${{ env.ASSEMBLE_DIR }} - name: Download Dokka - uses: actions/download-artifact@v4 - with: - name: dokka-${{ inputs.version }} - path: ${{ env.DOKKA_ARTIFACT }} + run: | + if [ -z "${{ inputs.build_id }}" ]; then + echo "'build_id' is not set" + exit 1 + fi + + echo "Downloading Dokka artifact, build id: ${{ inputs.build_id }}" + + artifact_url="https://krpc.teamcity.com/app/rest/builds/id:${{ inputs.build_id }}/artifacts/content/${{ env.DOKKA_ARTIFACT }}" + echo "Downloading Dokka artifact from URL: $artifact_url" + + curl -v -s -f -L -H "Authorization: Bearer ${{ secrets.TEAMCITY_TOKEN }}" "$artifact_url" -o "${{ env.DOKKA_ARTIFACT }}" + + if [ -z "$(ls | grep -x ${{ env.DOKKA_ARTIFACT }})" ]; then + echo "Failed to download Dokka artifact, asset id: ${{ inputs.build_id }}" + exit 1 + fi - name: Unzip Dokka run: unzip -O UTF-8 -qq '${{ env.DOKKA_ARTIFACT }}' -d ${{ env.ASSEMBLE_DIR }}/api @@ -110,7 +129,7 @@ jobs: retention-days: 7 deploy: - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && !inputs.dry_run environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -138,7 +157,7 @@ jobs: uses: actions/deploy-pages@v4 publish-indexes: - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && !inputs.dry_run needs: [ build, test, assemble, deploy ] runs-on: ubuntu-latest container: diff --git a/.github/workflows/dokka.yml b/.github/workflows/dokka.yml deleted file mode 100644 index 350d2d6c5..000000000 --- a/.github/workflows/dokka.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Store Dokka Artifact - -on: - workflow_dispatch: - inputs: - version: - description: 'Version of library that is being documented' - required: true - type: string - buildId: - description: 'TeamCity build id' - required: true - type: string - artifactName: - description: 'Name of artifact to download' - required: true - type: string - -jobs: - store-dokka-artifact: - name: Store Dokka Artifact - runs-on: ubuntu-latest - steps: - - name: Download Dokka artifact - run: | - curl -v -s -f -L \ - -H "Authorization: Bearer ${{ secrets.TEAMCITY_TOKEN }}" \ - https://krpc.teamcity.com/app/rest/builds/id:${{ inputs.buildId }}/artifacts/content/${{ inputs.artifactName }} -o dokka.zip - - name: Save artifact - uses: actions/upload-artifact@v4 - with: - name: dokka-${{ inputs.version }} - path: dokka.zip - retention-days: 21 diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/VersionSpecificApi.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/VersionSpecificApi.kt similarity index 90% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/VersionSpecificApi.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/VersionSpecificApi.kt index 6bc90b461..aa807afe4 100644 --- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/VersionSpecificApi.kt +++ b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/VersionSpecificApi.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ @file:Suppress("FunctionName") @@ -44,17 +44,10 @@ interface VersionSpecificApi { origin: IrDeclarationOrigin = this.origin, ): IrValueParameter - fun IrSimpleFunction.addExtensionReceiverVS( - type: IrType, - origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED, - ): IrValueParameter - var IrFieldBuilder.isFinalVS: Boolean var IrCall.originVS: IrStatementOrigin? - var IrConstructor.isPrimaryVS: Boolean - val IrConstructor.parametersVS: List val IrConstructorCall.argumentsVS: List @@ -91,7 +84,6 @@ interface VersionSpecificApi { ): IrConstructorCallImpl fun IrFunction.valueParametersVS(): List - val IrFunction.extensionReceiverParameterVS: IrValueParameter? var IrFunction.dispatchReceiverParameterVS: IrValueParameter? fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/IrMemberAccessExpressionBuilder.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/IrMemberAccessExpressionBuilder.kt similarity index 100% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/IrMemberAccessExpressionBuilder.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/IrMemberAccessExpressionBuilder.kt diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/IrUtils.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/IrUtils.kt similarity index 92% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/IrUtils.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/IrUtils.kt index 648c2eca2..5f3800ee7 100644 --- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/IrUtils.kt +++ b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/IrUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.extension @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.ir.types.SimpleTypeNullability import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.ir.util.dump -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance import java.util.* @@ -76,16 +75,10 @@ inline fun IrProperty.addBackingFieldUtil(builder: IrFieldBuilder.() -> Unit = { } } -// originally appeared as 'NameUtils.propertyDelegateName' -fun propertyDelegateName(propertyName: Name): Name { - return Name.identifier("${propertyName.asString()}\$delegate") -} - inline fun Collection.memoryOptimizedMap(transform: (T) -> R): List { return mapTo(ArrayList(size), transform).compactIfPossible() } - inline fun Collection.memoryOptimizedMapIndexed(transform: (index: Int, T) -> R): List { return mapIndexedTo(ArrayList(size), transform).compactIfPossible() } diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt similarity index 98% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt index 23a0492f0..f7296df0e 100644 --- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt +++ b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.extension diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrContext.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrContext.kt similarity index 100% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrContext.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrContext.kt diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrExtension.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrExtension.kt similarity index 100% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrExtension.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrExtension.kt diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrServiceProcessor.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrServiceProcessor.kt similarity index 100% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrServiceProcessor.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcIrServiceProcessor.kt diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcStubGenerator.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcStubGenerator.kt similarity index 100% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcStubGenerator.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/RpcStubGenerator.kt diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt similarity index 94% rename from compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt rename to compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt index 0af4fd2f6..98d0f19c9 100644 --- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt +++ b/compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/extension/ServiceDeclaration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.extension diff --git a/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt b/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt deleted file mode 100644 index 6f5a61a56..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.RpcIrContext -import kotlinx.rpc.codegen.extension.RpcIrServiceProcessor -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.visitors.IrTransformer - -internal class RpcIrServiceProcessorDelegate( - val processor: RpcIrServiceProcessor, -) : IrTransformer() { - override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement { - processor.visitClass(declaration, data) - - return super.visitClass(declaration, data) - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt deleted file mode 100644 index 7fa1298f0..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/latest/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.createExtensionReceiver -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfigurationKey -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.util.copyTo -import org.jetbrains.kotlin.ir.util.isNullable -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.isJs -import org.jetbrains.kotlin.platform.isWasm - -object VersionSpecificApiImpl : VersionSpecificApi { - override fun isJs(platform: TargetPlatform?): Boolean { - return platform.isJs() - } - - override fun isWasm(platform: TargetPlatform?): Boolean { - return platform.isWasm() - } - - override var IrFieldBuilder.isFinalVS: Boolean - get() = isFinal - set(value) { - isFinal = value - } - - override var IrCall.originVS: IrStatementOrigin? - get() = origin - set(value) { - origin = value - } - - override var IrConstructor.isPrimaryVS: Boolean - get() = isPrimary - set(value) { - isPrimary = value - } - - override val IrConstructor.parametersVS: List - get() = parameters - - override val IrConstructorCall.argumentsVS: List - get() = arguments.toList() - - override fun IrType.isNullableVS(): Boolean { - return isNullable() - } - - override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { - return context.referenceClass( - ClassId( - FqName(packageName), - FqName(name), - false - ) - ) - } - - override fun referenceFunctions( - context: IrPluginContext, - packageName: String, - name: String, - ): Collection { - return context.referenceFunctions( - CallableId( - FqName(packageName), - Name.identifier(name), - ) - ) - } - - override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { - return copyTo(irFunction, origin) - } - - override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { - return createExtensionReceiver(type, origin) - } - - override val messageCollectorKey: CompilerConfigurationKey - get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY - - override fun IrCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - origin: IrStatementOrigin?, - superQualifierSymbol: IrClassSymbol?, - ): IrCallImpl { - return IrCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - origin = origin, - superQualifierSymbol = superQualifierSymbol, - ) - } - - override fun IrConstructorCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - constructorTypeArgumentsCount: Int, - origin: IrStatementOrigin?, - source: SourceElement, - ): IrConstructorCallImpl { - return IrConstructorCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - constructorTypeArgumentsCount = constructorTypeArgumentsCount, - origin = origin, - source = source, - ) - } - - override fun IrFunction.valueParametersVS(): List { - return parameters.filter { it.kind == IrParameterKind.Regular } - } - - override val IrFunction.extensionReceiverParameterVS: IrValueParameter? - get() = parameters.firstOrNull { it.kind == IrParameterKind.ExtensionReceiver } - - override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? - get() = dispatchReceiverParameter - set(value) { - if (value != null) { - parameters += value - } - } - - override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { - var offset = if (dispatchReceiver != null) { - access.arguments[0] = dispatchReceiver - 1 - } else { - 0 - } - - offset += if (extensionReceiver != null) { - access.arguments[offset] = extensionReceiver - 1 - } else { - 0 - } - - valueArguments.forEachIndexed { index, irExpression -> - access.arguments[offset + index] = irExpression - } - - typeArguments.forEachIndexed { index, irType -> - access.typeArguments[index] = irType - } - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt deleted file mode 100644 index 0b9c1f0ac..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.RpcIrContext -import kotlinx.rpc.codegen.extension.RpcIrServiceProcessor -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.visitors.IrElementTransformer - -internal class RpcIrServiceProcessorDelegate( - val processor: RpcIrServiceProcessor, -) : IrElementTransformer { - override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement { - processor.visitClass(declaration, data) - - return super.visitClass(declaration, data) - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt deleted file mode 100644 index b5ab49638..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver -import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CompilerConfigurationKey -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments -import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.isNullable -import org.jetbrains.kotlin.ir.util.copyTo -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.isJs -import org.jetbrains.kotlin.platform.isWasm - -object VersionSpecificApiImpl : VersionSpecificApi { - override fun isJs(platform: TargetPlatform?): Boolean { - return platform.isJs() - } - - override fun isWasm(platform: TargetPlatform?): Boolean { - return platform.isWasm() - } - - override var IrFieldBuilder.isFinalVS: Boolean - get() = isFinal - set(value) { - isFinal = value - } - - override var IrCall.originVS: IrStatementOrigin? - get() = origin - set(value) { origin = value } - - override var IrConstructor.isPrimaryVS: Boolean - get() = isPrimary - set(value) { - isPrimary = value - } - - override val IrConstructor.parametersVS: List - get() = valueParameters - - override val IrConstructorCall.argumentsVS: List - get() = valueArguments - - override fun IrType.isNullableVS(): Boolean { - return isNullable() - } - - override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { - return context.referenceClass( - ClassId( - FqName(packageName), - FqName(name), - false - ) - ) - } - - override fun referenceFunctions( - context: IrPluginContext, - packageName: String, - name: String - ): Collection { - return context.referenceFunctions( - CallableId( - FqName(packageName), - Name.identifier(name), - ) - ) - } - - override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { - return copyTo(irFunction, origin) - } - - override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { - return addExtensionReceiver(type, origin) - } - - override val messageCollectorKey: CompilerConfigurationKey - get() = CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY - - override fun IrCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - origin: IrStatementOrigin?, - superQualifierSymbol: IrClassSymbol?, - ): IrCallImpl { - return IrCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - valueArgumentsCount = valueArgumentsCount, - origin = origin, - superQualifierSymbol = superQualifierSymbol, - ) - } - - override fun IrConstructorCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - constructorTypeArgumentsCount: Int, - origin: IrStatementOrigin?, - source: SourceElement, - ): IrConstructorCallImpl { - return IrConstructorCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - valueArgumentsCount = valueArgumentsCount, - constructorTypeArgumentsCount = constructorTypeArgumentsCount, - origin = origin, - source = source, - ) - } - - override fun IrFunction.valueParametersVS(): List { - return valueParameters - } - - override val IrFunction.extensionReceiverParameterVS: IrValueParameter? - get() = extensionReceiverParameter - - override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? - get() = dispatchReceiverParameter - set(value) { - dispatchReceiverParameter = value - } - - - override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { - access.dispatchReceiver = dispatchReceiver - access.extensionReceiver = extensionReceiver - - valueArguments.forEachIndexed { index, irExpression -> - access.putValueArgument(index, irExpression) - } - - typeArguments.forEachIndexed { index, irType -> - access.putTypeArgument(index, irType) - } - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt deleted file mode 100644 index 0b9c1f0ac..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.RpcIrContext -import kotlinx.rpc.codegen.extension.RpcIrServiceProcessor -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.visitors.IrElementTransformer - -internal class RpcIrServiceProcessorDelegate( - val processor: RpcIrServiceProcessor, -) : IrElementTransformer { - override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement { - processor.visitClass(declaration, data) - - return super.visitClass(declaration, data) - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt deleted file mode 100644 index 4c8dd5077..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_0_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfigurationKey -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments -import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.isNullable -import org.jetbrains.kotlin.ir.util.copyTo -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.isJs -import org.jetbrains.kotlin.platform.isWasm - -object VersionSpecificApiImpl : VersionSpecificApi { - override fun isJs(platform: TargetPlatform?): Boolean { - return platform.isJs() - } - - override fun isWasm(platform: TargetPlatform?): Boolean { - return platform.isWasm() - } - - override var IrFieldBuilder.isFinalVS: Boolean - get() = isFinal - set(value) { - isFinal = value - } - - override var IrCall.originVS: IrStatementOrigin? - get() = origin - set(value) { origin = value } - - override var IrConstructor.isPrimaryVS: Boolean - get() = isPrimary - set(value) { - isPrimary = value - } - - override val IrConstructor.parametersVS: List - get() = valueParameters - - override val IrConstructorCall.argumentsVS: List - get() = valueArguments - - override fun IrType.isNullableVS(): Boolean { - return isNullable() - } - - override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { - return context.referenceClass( - ClassId( - FqName(packageName), - FqName(name), - false - ) - ) - } - - override fun referenceFunctions( - context: IrPluginContext, - packageName: String, - name: String, - ): Collection { - return context.referenceFunctions( - CallableId( - FqName(packageName), - Name.identifier(name), - ) - ) - } - - override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { - return copyTo(irFunction, origin) - } - - override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { - return addExtensionReceiver(type, origin) - } - - override val messageCollectorKey: CompilerConfigurationKey - get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY - - override fun IrCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - origin: IrStatementOrigin?, - superQualifierSymbol: IrClassSymbol?, - ): IrCallImpl { - return IrCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - valueArgumentsCount = valueArgumentsCount, - origin = origin, - superQualifierSymbol = superQualifierSymbol, - ) - } - - override fun IrConstructorCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - constructorTypeArgumentsCount: Int, - origin: IrStatementOrigin?, - source: SourceElement, - ): IrConstructorCallImpl { - return IrConstructorCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - valueArgumentsCount = valueArgumentsCount, - constructorTypeArgumentsCount = constructorTypeArgumentsCount, - origin = origin, - source = source, - ) - } - - override fun IrFunction.valueParametersVS(): List { - return valueParameters - } - - override val IrFunction.extensionReceiverParameterVS: IrValueParameter? - get() = extensionReceiverParameter - - override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? - get() = dispatchReceiverParameter - set(value) { - dispatchReceiverParameter = value - } - - - override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { - access.dispatchReceiver = dispatchReceiver - access.extensionReceiver = extensionReceiver - - valueArguments.forEachIndexed { index, irExpression -> - access.putValueArgument(index, irExpression) - } - - typeArguments.forEachIndexed { index, irType -> - access.putTypeArgument(index, irType) - } - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt deleted file mode 100644 index e1327fed3..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfigurationKey -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments -import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.isNullable -import org.jetbrains.kotlin.ir.util.copyTo -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.isJs -import org.jetbrains.kotlin.platform.isWasm - -object VersionSpecificApiImpl : VersionSpecificApi { - override fun isJs(platform: TargetPlatform?): Boolean { - return platform.isJs() - } - - override fun isWasm(platform: TargetPlatform?): Boolean { - return platform.isWasm() - } - - override var IrFieldBuilder.isFinalVS: Boolean - get() = isFinal - set(value) { - isFinal = value - } - - override var IrCall.originVS: IrStatementOrigin? - get() = origin - set(value) { - origin = value - } - - override var IrConstructor.isPrimaryVS: Boolean - get() = isPrimary - set(value) { - isPrimary = value - } - - override val IrConstructor.parametersVS: List - get() = valueParameters - - override val IrConstructorCall.argumentsVS: List - get() = valueArguments - - override fun IrType.isNullableVS(): Boolean { - return isNullable() - } - - override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { - return context.referenceClass( - ClassId( - FqName(packageName), - FqName(name), - false - ) - ) - } - - override fun referenceFunctions( - context: IrPluginContext, - packageName: String, - name: String, - ): Collection { - return context.referenceFunctions( - CallableId( - FqName(packageName), - Name.identifier(name), - ) - ) - } - - override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { - return copyTo(irFunction, origin) - } - - override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { - return addExtensionReceiver(type, origin) - } - - override val messageCollectorKey: CompilerConfigurationKey - get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY - - override fun IrCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - origin: IrStatementOrigin?, - superQualifierSymbol: IrClassSymbol?, - ): IrCallImpl { - return IrCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - origin = origin, - superQualifierSymbol = superQualifierSymbol, - ) - } - - override fun IrConstructorCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - constructorTypeArgumentsCount: Int, - origin: IrStatementOrigin?, - source: SourceElement, - ): IrConstructorCallImpl { - return IrConstructorCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - constructorTypeArgumentsCount = constructorTypeArgumentsCount, - origin = origin, - source = source, - ) - } - - override fun IrFunction.valueParametersVS(): List { - return valueParameters - } - - override val IrFunction.extensionReceiverParameterVS: IrValueParameter? - get() = extensionReceiverParameter - - override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? - get() = dispatchReceiverParameter - set(value) { - dispatchReceiverParameter = value - } - - - override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { - if (dispatchReceiver != null) { - access.dispatchReceiver = dispatchReceiver - } - - if (extensionReceiver != null) { - access.extensionReceiver = extensionReceiver - } - - valueArguments.forEachIndexed { index, irExpression -> - access.putValueArgument(index, irExpression) - } - - typeArguments.forEachIndexed { index, irType -> - access.putTypeArgument(index, irType) - } - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt deleted file mode 100644 index 0b9c1f0ac..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.RpcIrContext -import kotlinx.rpc.codegen.extension.RpcIrServiceProcessor -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.visitors.IrElementTransformer - -internal class RpcIrServiceProcessorDelegate( - val processor: RpcIrServiceProcessor, -) : IrElementTransformer { - override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement { - processor.visitClass(declaration, data) - - return super.visitClass(declaration, data) - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt deleted file mode 100644 index fc2768863..000000000 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_21/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfigurationKey -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.util.copyTo -import org.jetbrains.kotlin.ir.util.isNullable -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.isJs -import org.jetbrains.kotlin.platform.isWasm - -object VersionSpecificApiImpl : VersionSpecificApi { - override fun isJs(platform: TargetPlatform?): Boolean { - return platform.isJs() - } - - override fun isWasm(platform: TargetPlatform?): Boolean { - return platform.isWasm() - } - - override var IrFieldBuilder.isFinalVS: Boolean - get() = isFinal - set(value) { - isFinal = value - } - - override var IrCall.originVS: IrStatementOrigin? - get() = origin - set(value) { - origin = value - } - - override var IrConstructor.isPrimaryVS: Boolean - get() = isPrimary - set(value) { - isPrimary = value - } - - override val IrConstructor.parametersVS: List - get() = parameters - - override val IrConstructorCall.argumentsVS: List - get() = arguments - - override fun IrType.isNullableVS(): Boolean { - return isNullable() - } - - override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { - return context.referenceClass( - ClassId( - FqName(packageName), - FqName(name), - false - ) - ) - } - - override fun referenceFunctions( - context: IrPluginContext, - packageName: String, - name: String, - ): Collection { - return context.referenceFunctions( - CallableId( - FqName(packageName), - Name.identifier(name), - ) - ) - } - - override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { - return copyTo(irFunction, origin) - } - - override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { - return addExtensionReceiver(type, origin) - } - - override val messageCollectorKey: CompilerConfigurationKey - get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY - - override fun IrCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - origin: IrStatementOrigin?, - superQualifierSymbol: IrClassSymbol?, - ): IrCallImpl { - return IrCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - origin = origin, - superQualifierSymbol = superQualifierSymbol, - ) - } - - override fun IrConstructorCallImplVS( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - typeArgumentsCount: Int, - valueArgumentsCount: Int, - constructorTypeArgumentsCount: Int, - origin: IrStatementOrigin?, - source: SourceElement, - ): IrConstructorCallImpl { - return IrConstructorCallImpl( - startOffset = startOffset, - endOffset = endOffset, - type = type, - symbol = symbol, - typeArgumentsCount = typeArgumentsCount, - constructorTypeArgumentsCount = constructorTypeArgumentsCount, - origin = origin, - source = source, - ) - } - - override fun IrFunction.valueParametersVS(): List { - return valueParameters - } - - override val IrFunction.extensionReceiverParameterVS: IrValueParameter? - get() = extensionReceiverParameter - - override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? - get() = dispatchReceiverParameter - set(value) { - dispatchReceiverParameter = value - } - - - override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { - if (dispatchReceiver != null) { - access.dispatchReceiver = dispatchReceiver - } - - if (extensionReceiver != null) { - access.extensionReceiver = extensionReceiver - } - - valueArguments.forEachIndexed { index, irExpression -> - access.putValueArgument(index, irExpression) - } - - typeArguments.forEachIndexed { index, irType -> - access.putTypeArgument(index, irType) - } - } -} diff --git a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt b/compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt similarity index 51% rename from compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt rename to compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt index 0b9c1f0ac..1eac98a3e 100644 --- a/compiler-plugin/compiler-plugin-backend/src/main/pre_2_1_10/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt +++ b/compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/RpcIrServiceProcessorDelegate.kt @@ -8,8 +8,17 @@ import kotlinx.rpc.codegen.extension.RpcIrContext import kotlinx.rpc.codegen.extension.RpcIrServiceProcessor import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrClass +//##csm RpcIrServiceProcessorDelegate.kt-import +//##csm specific=[2.0.0...2.1.21] import org.jetbrains.kotlin.ir.visitors.IrElementTransformer +//##csm /specific +//##csm default +import org.jetbrains.kotlin.ir.visitors.IrTransformer +//##csm /default +//##csm /RpcIrServiceProcessorDelegate.kt-import +//##csm RpcIrServiceProcessorDelegate +//##csm specific=[2.0.0...2.1.21] internal class RpcIrServiceProcessorDelegate( val processor: RpcIrServiceProcessor, ) : IrElementTransformer { @@ -19,3 +28,16 @@ internal class RpcIrServiceProcessorDelegate( return super.visitClass(declaration, data) } } +//##csm /specific +//##csm default +internal class RpcIrServiceProcessorDelegate( + val processor: RpcIrServiceProcessor, +) : IrTransformer() { + override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement { + processor.visitClass(declaration, data) + + return super.visitClass(declaration, data) + } +} +//##csm /default +//##csm /RpcIrServiceProcessorDelegate diff --git a/compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt new file mode 100644 index 000000000..4c9417b82 --- /dev/null +++ b/compiler-plugin/compiler-plugin-backend/src/main/templates/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt @@ -0,0 +1,387 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.rpc.codegen + +//##csm VersionSpecificApiImpl.kt-import +//##csm specific=[2.0.0...2.0.10] +import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.isNullable +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm +//##csm /specific +//##csm specific=[2.0.11...2.0.21] +import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.isNullable +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm +//##csm /specific +//##csm specific=[2.0.22...2.1.10, 2.1.20-ij243-*] +import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.isNullable +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm +//##csm /specific +//##csm specific=[2.1.11...2.1.21] +import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.ir.util.isNullable +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm +//##csm /specific +//##csm specific=[2.1.22...2.*] +import kotlinx.rpc.codegen.extension.IrMemberAccessExpressionData +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.ir.util.isNullable +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm +//##csm /specific +//##csm /VersionSpecificApiImpl.kt-import + +object VersionSpecificApiImpl : VersionSpecificApi { + override fun isJs(platform: TargetPlatform?): Boolean { + return platform.isJs() + } + + override fun isWasm(platform: TargetPlatform?): Boolean { + return platform.isWasm() + } + + override var IrFieldBuilder.isFinalVS: Boolean + get() = isFinal + set(value) { + isFinal = value + } + + override var IrCall.originVS: IrStatementOrigin? + get() = origin + set(value) { origin = value } + + //##csm IrConstructor.parametersVS + //##csm specific=[2.0.0...2.1.10, 2.1.20-ij243-*] + override val IrConstructor.parametersVS: List + get() = valueParameters + //##csm /specific + //##csm default + override val IrConstructor.parametersVS: List + get() = parameters + //##csm /default + //##csm /IrConstructor.parametersVS + + //##csm IrConstructorCall.argumentsVS + //##csm specific=[2.0.0...2.1.10, 2.1.20-ij243-*] + override val IrConstructorCall.argumentsVS: List + get() = valueArguments + //##csm /specific + //##csm specific=[2.1.11...2.1.21] + override val IrConstructorCall.argumentsVS: List + get() = arguments + //##csm /specific + //##csm default + override val IrConstructorCall.argumentsVS: List + get() = arguments.toList() + //##csm /default + //##csm /IrConstructorCall.argumentsVS + + override fun IrType.isNullableVS(): Boolean { + return isNullable() + } + + override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { + return context.referenceClass( + ClassId( + FqName(packageName), + FqName(name), + false + ) + ) + } + + override fun referenceFunctions( + context: IrPluginContext, + packageName: String, + name: String + ): Collection { + return context.referenceFunctions( + CallableId( + FqName(packageName), + Name.identifier(name), + ) + ) + } + + override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { + return copyTo(irFunction, origin) + } + + //##csm messageCollectorKey + //##csm specific=[2.0.0...2.0.10] + override val messageCollectorKey: CompilerConfigurationKey + get() = CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY + //##csm /specific + //##csm default + override val messageCollectorKey: CompilerConfigurationKey + get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY + //##csm /default + //##csm /messageCollectorKey + + override fun IrCallImplVS( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrSimpleFunctionSymbol, + typeArgumentsCount: Int, + valueArgumentsCount: Int, + origin: IrStatementOrigin?, + superQualifierSymbol: IrClassSymbol?, + ): IrCallImpl { + return IrCallImpl( + startOffset = startOffset, + endOffset = endOffset, + type = type, + symbol = symbol, + typeArgumentsCount = typeArgumentsCount, + //##csm IrCallImplVS + //##csm specific=[2.0.0...2.0.21] + valueArgumentsCount = valueArgumentsCount, + //##csm /specific + //##csm /IrCallImplVS + origin = origin, + superQualifierSymbol = superQualifierSymbol, + ) + } + + override fun IrConstructorCallImplVS( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrConstructorSymbol, + typeArgumentsCount: Int, + valueArgumentsCount: Int, + constructorTypeArgumentsCount: Int, + origin: IrStatementOrigin?, + source: SourceElement, + ): IrConstructorCallImpl { + return IrConstructorCallImpl( + startOffset = startOffset, + endOffset = endOffset, + type = type, + symbol = symbol, + typeArgumentsCount = typeArgumentsCount, + //##csm IrConstructorCallImplVS + //##csm specific=[2.0.0...2.0.21] + valueArgumentsCount = valueArgumentsCount, + //##csm /specific + //##csm /IrConstructorCallImplVS + constructorTypeArgumentsCount = constructorTypeArgumentsCount, + origin = origin, + source = source, + ) + } + + //##csm IrFunction.valueParametersVS + //##csm specific=[2.0.0...2.1.21] + override fun IrFunction.valueParametersVS(): List { + return valueParameters + } + //##csm /specific + //##csm default + override fun IrFunction.valueParametersVS(): List { + return parameters.filter { it.kind == IrParameterKind.Regular } + } + //##csm /default + //##csm /IrFunction.valueParametersVS + + override var IrFunction.dispatchReceiverParameterVS: IrValueParameter? + get() = dispatchReceiverParameter + set(value) { + //##csm IrFunction.extensionReceiverParameterVS + //##csm specific=[2.0.0...2.1.21] + dispatchReceiverParameter = value + //##csm /specific + //##csm default + if (value != null) { + parameters += value + } + //##csm /default + //##csm /IrFunction.extensionReceiverParameterVS + } + + override fun IrMemberAccessExpressionData.buildFor(access: IrMemberAccessExpression<*>) { + //##csm IrMemberAccessExpressionData.buildFor + //##csm specific=[2.0.0...2.0.21] + access.dispatchReceiver = dispatchReceiver + access.extensionReceiver = extensionReceiver + + valueArguments.forEachIndexed { index, irExpression -> + access.putValueArgument(index, irExpression) + } + + typeArguments.forEachIndexed { index, irType -> + access.putTypeArgument(index, irType) + } + //##csm /specific + //##csm specific=[2.0.22...2.1.21] + if (dispatchReceiver != null) { + access.dispatchReceiver = dispatchReceiver + } + + if (extensionReceiver != null) { + access.extensionReceiver = extensionReceiver + } + valueArguments.forEachIndexed { index, irExpression -> + access.putValueArgument(index, irExpression) + } + + typeArguments.forEachIndexed { index, irType -> + access.putTypeArgument(index, irType) + } + //##csm /specific + //##csm default + var offset = if (dispatchReceiver != null) { + access.arguments[0] = dispatchReceiver + 1 + } else { + 0 + } + + offset += if (extensionReceiver != null) { + access.arguments[offset] = extensionReceiver + 1 + } else { + 0 + } + + valueArguments.forEachIndexed { index, irExpression -> + access.arguments[offset + index] = irExpression + } + + typeArguments.forEachIndexed { index, irType -> + access.typeArguments[index] = irType + } + //##csm /default + //##csm /IrMemberAccessExpressionData.buildFor + } +} diff --git a/compiler-plugin/compiler-plugin-cli/src/main/latest/kotlinx/rpc/codegen/RpcCompilerPlugin.kt b/compiler-plugin/compiler-plugin-cli/src/main/kotlin/kotlinx/rpc/codegen/RpcCompilerPlugin.kt similarity index 96% rename from compiler-plugin/compiler-plugin-cli/src/main/latest/kotlinx/rpc/codegen/RpcCompilerPlugin.kt rename to compiler-plugin/compiler-plugin-cli/src/main/kotlin/kotlinx/rpc/codegen/RpcCompilerPlugin.kt index d450e67a3..9c635541f 100644 --- a/compiler-plugin/compiler-plugin-cli/src/main/latest/kotlinx/rpc/codegen/RpcCompilerPlugin.kt +++ b/compiler-plugin/compiler-plugin-cli/src/main/kotlin/kotlinx/rpc/codegen/RpcCompilerPlugin.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen diff --git a/compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor b/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor similarity index 61% rename from compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor rename to compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor index faa9c2452..aa1e65776 100644 --- a/compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor +++ b/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor @@ -1,5 +1,5 @@ # -# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. +# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. # kotlinx.rpc.codegen.RpcCommandLineProcessor diff --git a/compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar b/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar similarity index 60% rename from compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar rename to compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar index 1df6db12e..1571fca49 100644 --- a/compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +++ b/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar @@ -1,5 +1,5 @@ # -# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. +# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. # kotlinx.rpc.codegen.RpcCompilerPlugin diff --git a/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt b/compiler-plugin/compiler-plugin-common/src/main/kotlin/kotlinx/rpc/codegen/common/Names.kt similarity index 94% rename from compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt rename to compiler-plugin/compiler-plugin-common/src/main/kotlin/kotlinx/rpc/codegen/common/Names.kt index 23523d760..7b3ce88cb 100644 --- a/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt +++ b/compiler-plugin/compiler-plugin-common/src/main/kotlin/kotlinx/rpc/codegen/common/Names.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.common diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirGenerationKeys.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirGenerationKeys.kt similarity index 92% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirGenerationKeys.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirGenerationKeys.kt index 0b0417ef8..fd85c1440 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirGenerationKeys.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirGenerationKeys.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt similarity index 96% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt index 8d701b0ca..fce3e3c2c 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcAdditionalCheckers.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt similarity index 94% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt index 735154cb5..8a9626e98 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcExtensionRegistrar.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcPredicates.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcPredicates.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcPredicates.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcPredicates.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcServiceGenerator.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcServiceGenerator.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcServiceGenerator.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcServiceGenerator.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcUtils.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcUtils.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcUtils.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcUtils.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirVersionSpecificApi.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirVersionSpecificApi.kt similarity index 63% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirVersionSpecificApi.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirVersionSpecificApi.kt index 0edbec959..5d4e59b29 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirVersionSpecificApi.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirVersionSpecificApi.kt @@ -4,35 +4,20 @@ package kotlinx.rpc.codegen -import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder interface FirVersionSpecificApi { - fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement? = null, - delegatedTypeRef: FirTypeRef? = null, - ): FirResolvedTypeRef - fun ConeKotlinType.toClassSymbolVS( session: FirSession, ): FirClassSymbol<*>? - var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - - fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> - - fun FirRegularClassSymbol.constructorsVS(session: FirSession): List - fun FirRegularClass.declarationsVS(session: FirSession): List> val FirResolvedTypeRef.coneTypeVS: ConeKotlinType diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/RpcFirCliOptions.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/RpcFirCliOptions.kt similarity index 91% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/RpcFirCliOptions.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/RpcFirCliOptions.kt index 51c720671..88c11dd44 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/RpcFirCliOptions.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/RpcFirCliOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirCheckedAnnotationCheckers.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirCheckedAnnotationCheckers.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirCheckedAnnotationCheckers.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirCheckedAnnotationCheckers.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcAnnotationChecker.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcAnnotationChecker.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcAnnotationChecker.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcAnnotationChecker.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt similarity index 96% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt index 343a86df7..6b66f90d3 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcCheckers.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.checkers diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt similarity index 97% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt index 52417ff7d..156dea13a 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcServiceDeclarationChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.checkers diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt similarity index 99% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt index 208630e0c..abe484cac 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/FirRpcStrictModeClassChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc.codegen.checkers diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/SerializableProperties.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/SerializableProperties.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/SerializableProperties.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/SerializableProperties.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/FirRpcDiagnostics.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/FirRpcDiagnostics.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/FirRpcDiagnostics.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/FirRpcDiagnostics.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/RpcDiagnosticRendererFactory.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcDiagnosticRendererFactory.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/RpcDiagnosticRendererFactory.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcDiagnosticRendererFactory.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainerCore.kt b/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainerCore.kt similarity index 100% rename from compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainerCore.kt rename to compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainerCore.kt diff --git a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index 989ff638b..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.declaredFunctions -import org.jetbrains.kotlin.fir.declarations.constructors -import org.jetbrains.kotlin.fir.resolve.toClassSymbol -import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.processAllDeclarations -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = coneType - set(value) { - coneType = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - return declaredFunctions(session) - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return constructors(session) - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - val declarations = mutableListOf>() - processAllDeclarations(session) { symbol -> - declarations.add(symbol) - } - return declarations - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = coneType - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt deleted file mode 100644 index b1c80d91a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -abstract class RpcKtDiagnosticsContainer : RpcKtDiagnosticsContainerCore diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index a89b7c903..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.types.ConeClassLikeType -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder -import org.jetbrains.kotlin.fir.types.toClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.symbols.SymbolInternals -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol -import org.jetbrains.kotlin.fir.types.toRegularClassSymbol - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return (this as? ConeClassLikeType)?.toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = type - set(value) { - type = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - @OptIn(SymbolInternals::class) - return fir.declarations - .filterIsInstance() - .map { it.symbol } - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return declarationSymbols.filterIsInstance() - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - return declarations.map { it.symbol } - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = type - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt deleted file mode 100644 index 0dc9e1f59..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers - -import kotlinx.rpc.codegen.FirCheckersContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTypeParameterChecker -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall - -class FirCheckedAnnotationFunctionCallCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionCallChecker(MppCheckerKind.Common) { - override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) - } -} - -class FirCheckedAnnotationTypeParameterCheckerVS( - private val ctx: FirCheckersContext, -) : FirTypeParameterChecker(MppCheckerKind.Common) { - override fun check(declaration: FirTypeParameter, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirClassCheckerVS( - private val ctx: FirCheckersContext, -) : FirClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirFunctionCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionChecker(MppCheckerKind.Common) { - override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcAnnotationChecker.check(declaration, context, reporter) - } -} - -class FirRpcServiceDeclarationCheckerVS( - private val ctx: FirCheckersContext, -) : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcStrictModeClassChecker.check(declaration, context, reporter) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt deleted file mode 100644 index 50f2a99fb..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap - -fun RpcKtDiagnosticFactoryToRendererMap( - name: String, - init: (KtDiagnosticFactoryToRendererMap) -> Unit, -): Lazy { - return lazy(LazyThreadSafetyMode.SYNCHRONIZED) { - KtDiagnosticFactoryToRendererMap(name).also(init) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt deleted file mode 100644 index b1c80d91a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_10/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -abstract class RpcKtDiagnosticsContainer : RpcKtDiagnosticsContainerCore diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index d52bf68c0..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder -import org.jetbrains.kotlin.fir.types.toClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.symbols.SymbolInternals -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol -import org.jetbrains.kotlin.fir.types.toRegularClassSymbol - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = type - set(value) { - type = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - @OptIn(SymbolInternals::class) - return fir.declarations - .filterIsInstance() - .map { it.symbol } - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return declarationSymbols.filterIsInstance() - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - return declarations.map { it.symbol } - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = type - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt deleted file mode 100644 index 0dc9e1f59..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers - -import kotlinx.rpc.codegen.FirCheckersContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTypeParameterChecker -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall - -class FirCheckedAnnotationFunctionCallCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionCallChecker(MppCheckerKind.Common) { - override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) - } -} - -class FirCheckedAnnotationTypeParameterCheckerVS( - private val ctx: FirCheckersContext, -) : FirTypeParameterChecker(MppCheckerKind.Common) { - override fun check(declaration: FirTypeParameter, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirClassCheckerVS( - private val ctx: FirCheckersContext, -) : FirClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirFunctionCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionChecker(MppCheckerKind.Common) { - override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcAnnotationChecker.check(declaration, context, reporter) - } -} - -class FirRpcServiceDeclarationCheckerVS( - private val ctx: FirCheckersContext, -) : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcStrictModeClassChecker.check(declaration, context, reporter) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt deleted file mode 100644 index 50f2a99fb..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap - -fun RpcKtDiagnosticFactoryToRendererMap( - name: String, - init: (KtDiagnosticFactoryToRendererMap) -> Unit, -): Lazy { - return lazy(LazyThreadSafetyMode.SYNCHRONIZED) { - KtDiagnosticFactoryToRendererMap(name).also(init) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt deleted file mode 100644 index b1c80d91a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_0_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -abstract class RpcKtDiagnosticsContainer : RpcKtDiagnosticsContainerCore diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index ea33c8657..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.resolve.toClassSymbol -import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.SymbolInternals -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = coneType - set(value) { - coneType = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - @OptIn(SymbolInternals::class) - return fir.declarations - .filterIsInstance() - .map { it.symbol } - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return declarationSymbols.filterIsInstance() - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - return declarations.map { it.symbol } - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = coneType - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt deleted file mode 100644 index 0dc9e1f59..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers - -import kotlinx.rpc.codegen.FirCheckersContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTypeParameterChecker -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall - -class FirCheckedAnnotationFunctionCallCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionCallChecker(MppCheckerKind.Common) { - override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) - } -} - -class FirCheckedAnnotationTypeParameterCheckerVS( - private val ctx: FirCheckersContext, -) : FirTypeParameterChecker(MppCheckerKind.Common) { - override fun check(declaration: FirTypeParameter, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirClassCheckerVS( - private val ctx: FirCheckersContext, -) : FirClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirFunctionCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionChecker(MppCheckerKind.Common) { - override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { - FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcAnnotationChecker.check(declaration, context, reporter) - } -} - -class FirRpcServiceDeclarationCheckerVS( - private val ctx: FirCheckersContext, -) : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - FirRpcStrictModeClassChecker.check(declaration, context, reporter) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt deleted file mode 100644 index 50f2a99fb..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap - -fun RpcKtDiagnosticFactoryToRendererMap( - name: String, - init: (KtDiagnosticFactoryToRendererMap) -> Unit, -): Lazy { - return lazy(LazyThreadSafetyMode.SYNCHRONIZED) { - KtDiagnosticFactoryToRendererMap(name).also(init) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt deleted file mode 100644 index b1c80d91a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/pre_2_1_21/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -abstract class RpcKtDiagnosticsContainer : RpcKtDiagnosticsContainerCore diff --git a/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt new file mode 100644 index 000000000..4bce9547e --- /dev/null +++ b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt @@ -0,0 +1,121 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.rpc.codegen + +//##csm FirVersionSpecificApiImpl.kt-import +//##csm specific=[2.0.0...2.0.10] +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.types.ConeClassLikeType +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.toClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +import org.jetbrains.kotlin.fir.types.toRegularClassSymbol +//##csm /specific +//##csm specific=[2.0.11...2.0.21] +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.toClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +import org.jetbrains.kotlin.fir.types.toRegularClassSymbol +//##csm /specific +//##csm specific=[2.0.22...2.1.21, 2.2.0-ij251-*] +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.resolve.toClassSymbol +import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +//##csm /specific +//##csm specific=[2.1.22...2.2.10] +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.resolve.toClassSymbol +import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.processAllDeclarations +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +//##csm /specific +//##csm specific=[2.2.20...2.*] +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.resolve.toClassSymbol +import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.processAllDeclarations +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +//##csm /specific +//##csm /FirVersionSpecificApiImpl.kt-import + +object FirVersionSpecificApiImpl : FirVersionSpecificApi { + override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { + //##csm ConeKotlinType.toClassSymbolVS + //##csm specific=[2.0.0...2.0.10] + return (this as? ConeClassLikeType)?.toClassSymbol(session) + //##csm /specific + //##csm default + return toClassSymbol(session) + //##csm /default + //##csm /ConeKotlinType.toClassSymbolVS + } + + override fun FirRegularClass.declarationsVS(session: FirSession): List> { + //##csm FirRegularClass.declarationsVS + //##csm default + val declarations = mutableListOf>() + processAllDeclarations(session) { symbol -> + declarations.add(symbol) + } + return declarations + //##csm /default + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + return declarations.map { it.symbol } + //##csm /specific + //##csm /FirRegularClass.declarationsVS + } + + //##csm FirResolvedTypeRef.coneTypeVS + //##csm default + override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = coneType + //##csm /default + //##csm specific=[2.0.0...2.0.21] + override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = type + //##csm /specific + //##csm /FirResolvedTypeRef.coneTypeVS + + override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { + return toRegularClassSymbol(session) + } + + override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { + return toRegularClassSymbol(session) + } +} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt similarity index 53% rename from compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt rename to compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt index 319548b6a..790d7110e 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt @@ -22,58 +22,121 @@ import org.jetbrains.kotlin.fir.expressions.FirFunctionCall class FirCheckedAnnotationFunctionCallCheckerVS( private val ctx: FirCheckersContext, ) : FirFunctionCallChecker(MppCheckerKind.Common) { + //##csm FirCheckedAnnotationFunctionCallCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { + FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(expression: FirFunctionCall) { FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) } + //##csm /default + //##csm /FirCheckedAnnotationFunctionCallCheckerVS_context } class FirCheckedAnnotationTypeParameterCheckerVS( private val ctx: FirCheckersContext, ) : FirTypeParameterChecker(MppCheckerKind.Common) { + //##csm FirCheckedAnnotationTypeParameterCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirTypeParameter, context: CheckerContext, reporter: DiagnosticReporter) { + FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirTypeParameter) { FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) } + //##csm /default + //##csm /FirCheckedAnnotationTypeParameterCheckerVS_context } class FirCheckedAnnotationFirClassCheckerVS( private val ctx: FirCheckersContext, ) : FirClassChecker(MppCheckerKind.Common) { + //##csm FirCheckedAnnotationFirClassCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) { + FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirClass) { FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) } + //##csm /default + //##csm /FirCheckedAnnotationFirClassCheckerVS_context } class FirCheckedAnnotationFirFunctionCheckerVS( private val ctx: FirCheckersContext, ) : FirFunctionChecker(MppCheckerKind.Common) { + //##csm FirCheckedAnnotationFirFunctionCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { + FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirFunction) { FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) } + //##csm /default + //##csm /FirCheckedAnnotationFirFunctionCheckerVS_context } class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { + //##csm FirRpcAnnotationCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { + FirRpcAnnotationChecker.check(declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirRegularClass) { FirRpcAnnotationChecker.check(declaration, context, reporter) } + //##csm /default + //##csm /FirRpcAnnotationCheckerVS_context } class FirRpcServiceDeclarationCheckerVS( private val ctx: FirCheckersContext, ) : FirRegularClassChecker(MppCheckerKind.Common) { + //##csm FirRpcServiceDeclarationCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { + FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirRegularClass) { FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) } + //##csm /default + //##csm /FirRpcServiceDeclarationCheckerVS_context } class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { + //##csm FirRpcStrictModeClassCheckerVS_context + //##csm specific=[2.0.0...2.1.21, 2.2.0-ij251-*] + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { + FirRpcStrictModeClassChecker.check(declaration, context, reporter) + } + //##csm /specific + //##csm default context(context: CheckerContext, reporter: DiagnosticReporter) override fun check(declaration: FirRegularClass) { FirRpcStrictModeClassChecker.check(declaration, context, reporter) } + //##csm /default + //##csm /FirRpcStrictModeClassCheckerVS_context } diff --git a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt similarity index 67% rename from compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt rename to compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt index 50f2a99fb..4d416c67f 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/latest/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt @@ -10,7 +10,14 @@ fun RpcKtDiagnosticFactoryToRendererMap( name: String, init: (KtDiagnosticFactoryToRendererMap) -> Unit, ): Lazy { + //##csm RpcKtDiagnosticFactoryToRendererMap + //##csm specific=[2.0.0...2.2.10] return lazy(LazyThreadSafetyMode.SYNCHRONIZED) { KtDiagnosticFactoryToRendererMap(name).also(init) } + //##csm /specific + //##csm default + return KtDiagnosticFactoryToRendererMap(name, init) + //##csm /default + //##csm /RpcKtDiagnosticFactoryToRendererMap } diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt similarity index 70% rename from compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt rename to compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt index 69e15c901..3410b189f 100644 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ b/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt @@ -4,6 +4,11 @@ package kotlinx.rpc.codegen.checkers.diagnostics +//##csm RpcKtDiagnosticsContainer +//##csm specific=[2.0.0...2.2.10] +abstract class RpcKtDiagnosticsContainer : RpcKtDiagnosticsContainerCore +//##csm /specific +//##csm default import org.jetbrains.kotlin.diagnostics.KtDiagnosticsContainer import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory @@ -12,3 +17,5 @@ abstract class RpcKtDiagnosticsContainer : KtDiagnosticsContainer(), RpcKtDiagno return getRendererFactoryVs() } } +//##csm /default +//##csm /RpcKtDiagnosticsContainer diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index 989ff638b..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.declaredFunctions -import org.jetbrains.kotlin.fir.declarations.constructors -import org.jetbrains.kotlin.fir.resolve.toClassSymbol -import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.processAllDeclarations -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = coneType - set(value) { - coneType = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - return declaredFunctions(session) - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return constructors(session) - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - val declarations = mutableListOf>() - processAllDeclarations(session) { symbol -> - declarations.add(symbol) - } - return declarations - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = coneType - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt deleted file mode 100644 index 319548b6a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers - -import kotlinx.rpc.codegen.FirCheckersContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTypeParameterChecker -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall - -class FirCheckedAnnotationFunctionCallCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionCallChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(expression: FirFunctionCall) { - FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) - } -} - -class FirCheckedAnnotationTypeParameterCheckerVS( - private val ctx: FirCheckersContext, -) : FirTypeParameterChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirTypeParameter) { - FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirClassCheckerVS( - private val ctx: FirCheckersContext, -) : FirClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirClass) { - FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirFunctionCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirFunction) { - FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcAnnotationChecker.check(declaration, context, reporter) - } -} - -class FirRpcServiceDeclarationCheckerVS( - private val ctx: FirCheckersContext, -) : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcStrictModeClassChecker.check(declaration, context, reporter) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt deleted file mode 100644 index 10750d1f2..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_2_2/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap - -fun RpcKtDiagnosticFactoryToRendererMap( - name: String, - init: (KtDiagnosticFactoryToRendererMap) -> Unit, -): Lazy { - return KtDiagnosticFactoryToRendererMap(name, init) -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt deleted file mode 100644 index 989ff638b..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/FirVersionSpecificApiImpl.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.declaredFunctions -import org.jetbrains.kotlin.fir.declarations.constructors -import org.jetbrains.kotlin.fir.resolve.toClassSymbol -import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.toFirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.processAllDeclarations -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol - -object FirVersionSpecificApiImpl : FirVersionSpecificApi { - override fun ConeKotlinType.toFirResolvedTypeRefVS( - source: KtSourceElement?, - delegatedTypeRef: FirTypeRef?, - ): FirResolvedTypeRef { - return toFirResolvedTypeRef(source, delegatedTypeRef) - } - - override fun ConeKotlinType.toClassSymbolVS(session: FirSession): FirClassSymbol<*>? { - return toClassSymbol(session) - } - - override var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType - get() = coneType - set(value) { - coneType = value - } - - override fun FirClassSymbol<*>.declaredFunctionsVS(session: FirSession): List> { - return declaredFunctions(session) - } - - override fun FirRegularClassSymbol.constructorsVS(session: FirSession): List { - return constructors(session) - } - - override fun FirRegularClass.declarationsVS(session: FirSession): List> { - val declarations = mutableListOf>() - processAllDeclarations(session) { symbol -> - declarations.add(symbol) - } - return declarations - } - - override val FirResolvedTypeRef.coneTypeVS: ConeKotlinType get() = coneType - - override fun FirTypeRef.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } - - override fun ConeKotlinType.toRegularClassSymbolVS(session: FirSession): FirRegularClassSymbol? { - return toRegularClassSymbol(session) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt deleted file mode 100644 index 319548b6a..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers - -import kotlinx.rpc.codegen.FirCheckersContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTypeParameterChecker -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall - -class FirCheckedAnnotationFunctionCallCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionCallChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(expression: FirFunctionCall) { - FirCheckedAnnotationFunctionCallChecker.check(ctx, expression, context, reporter) - } -} - -class FirCheckedAnnotationTypeParameterCheckerVS( - private val ctx: FirCheckersContext, -) : FirTypeParameterChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirTypeParameter) { - FirCheckedAnnotationTypeParameterChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirClassCheckerVS( - private val ctx: FirCheckersContext, -) : FirClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirClass) { - FirCheckedAnnotationFirClassChecker.check(ctx, declaration, context, reporter) - } -} - -class FirCheckedAnnotationFirFunctionCheckerVS( - private val ctx: FirCheckersContext, -) : FirFunctionChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirFunction) { - FirCheckedAnnotationFirFunctionChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcAnnotationCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcAnnotationChecker.check(declaration, context, reporter) - } -} - -class FirRpcServiceDeclarationCheckerVS( - private val ctx: FirCheckersContext, -) : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcServiceDeclarationChecker.check(ctx, declaration, context, reporter) - } -} - -class FirRpcStrictModeClassCheckerVS : FirRegularClassChecker(MppCheckerKind.Common) { - context(context: CheckerContext, reporter: DiagnosticReporter) - override fun check(declaration: FirRegularClass) { - FirRpcStrictModeClassChecker.check(declaration, context, reporter) - } -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt deleted file mode 100644 index 10750d1f2..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap - -fun RpcKtDiagnosticFactoryToRendererMap( - name: String, - init: (KtDiagnosticFactoryToRendererMap) -> Unit, -): Lazy { - return KtDiagnosticFactoryToRendererMap(name, init) -} diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt deleted file mode 100644 index 69e15c901..000000000 --- a/compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainer.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.rpc.codegen.checkers.diagnostics - -import org.jetbrains.kotlin.diagnostics.KtDiagnosticsContainer -import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory - -abstract class RpcKtDiagnosticsContainer : KtDiagnosticsContainer(), RpcKtDiagnosticsContainerCore { - override fun getRendererFactory(): BaseDiagnosticRendererFactory { - return getRendererFactoryVs() - } -} diff --git a/docs/environment.md b/docs/environment.md index b1795a318..d65f225b2 100644 --- a/docs/environment.md +++ b/docs/environment.md @@ -166,47 +166,72 @@ Here goes all heavy lifting codegen #### Compiler Specific Modules -> [!NOTE] Has its drawbacks, maybe we'll redesign later. - We have a problem when developing a Kotlin compiler plugin: Compiler API is not stable (not won't be for a while). So how can one develop a plugin that works stably? We compile for multiple Kotlin versions at once! We use an in-house ✨technology✨ for this: CSM or Compiler Specific Modules. -The idea is to substitute source sets depending on the current kotlin compiler version +This is a templating engine, which resolution is based on the current kotlin compiler version (`kotlin-compiler` in [libs.versions.toml](../versions-root/libs.versions.toml)). -There is always a `core` source set (like this: [core](../compiler-plugin/compiler-plugin-k2/src/main/core)) +There is always a core source set (like this: [kotlin](../compiler-plugin/compiler-plugin-k2/src/main/kotlin)) that compiles nicely on all Kotlin versions. It is the majority of the code. -And then we have source sets that are swapped for a specific version -(check other directories in the [main](../compiler-plugin/compiler-plugin-k2/src/main)). +And then we have a template set, which is processed before compilation for a specific version. +([templates](../compiler-plugin/compiler-plugin-k2/src/main/templates)). -The code that swaps them is in [compiler-specific-module.gradle.kts](../gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts). +The code that swaps them is in [template.kt](../gradle-conventions/src/main/kotlin/util/csm/template.kt). The rules are the following: -- Check all source sets that start with `v_` (for example, `v_2_2`, `v_2_1`, `v_2_2_2`). -It matches the most specific like a tree (so for `2.2.20` it will be `v_2_2_2`, for `2.2.10` - `v_2_2` and for `2.3.0` none). -If found one - its taken. -- If none, then check all that start with `pre_` (for example, `pre_2_0_10`, `pre_2_1_0`, `pre_2_2_0`). -Again, it matches the most specific inclusively, but chronologically -(for `2.1.0` it will be `pre_2_1_0`, for `2.0.0` - `pre_2_0_10`, for `2.3.0` none) -- Take `latest` otherwise -- Suffixes don't matter (`2.2.0` and `2.2.0-RC` are considered the same) - -It allows supporting some past and future Kotlin versions +- We enclose code dependent on a version in `##csm` tags. +- Every such block must: + - Start with `//##csm ` + - End with `//##csm /` + - Specify inside zero of more of the code blocks: + - `//##csm default` + `//##csm /default` + - `//##csm specific=[]` + `//##csm /specific` + +Example code: +```kotlin +fun functionAvailableInAllVersions() { + +} +fun csmFunction() { + //##csm my-block + //##csm default + return 1 + //##csm /default + //##csm specific=[2.0.0...2.1.0, 2.1.0-ij-*] + return 2 + //##csm /specific + //##csm /my-block +} +``` + +Templates matches `specific` versions greedy, so with multiple `specific` blocks - first one matched will be chosen, +or `default` if none, or nothing if there is no `default`. + +`` works like this: +- It's a comma-separated array of versions matchers +- Version matcher is either: + - Range — consists of `from` and `to` version separated by `...`. + `From` must be an exact version without a suffix. + `To` must be a version without a suffix, where `*` can be used for any part: `2.2.*`, `2.*` but not `2.2.2*`. + - Prefix matcher — matches a version by prefix: `2.2.0-*`, `2.2.2*`, `2.3.0-dev-*` + +This allows us to support some past and future Kotlin versions (including versions for IDE, which are not in the stable list nor generally public) simultaneously. -Rule for complier API breaking changes: +Rules for complier API breaking changes: - If some function or property changed signature or was replaced by another - -use `VersionSpecificApi` interface in `core` to declare functionality -and write the implementation in **all** other source sets -(see [FirVersionSpecificApi.kt](../compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirVersionSpecificApi.kt) -and [VersionSpecificApi.kt](../compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/VersionSpecificApi.kt)). +use `VersionSpecificApi` interface in core to declare functionality +(see [FirVersionSpecificApi.kt](../compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirVersionSpecificApi.kt) +and [VersionSpecificApi.kt](../compiler-plugin/compiler-plugin-backend/src/main/kotlin/kotlinx/rpc/codegen/VersionSpecificApi.kt)). - If some class differs in signature, -write a proxy in `core` and implementation in source sets. FQ name must match exactly -(see [FirRpcCheckersVS.kt](../compiler-plugin/compiler-plugin-k2/src/main/v_2_3/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt)) -as an example, and all classes with the same names in other source sets. +write a proxy in core and implementation in the template. +FQ name must match exactly. +(see [FirRpcCheckersVS.kt](../compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/FirRpcCheckersVS.kt) +as an example) TeamCity is set up to work with multiple Kotlin versions for testing and releases. @@ -365,14 +390,14 @@ Here is a 'simple' guide for solving problems: - `Cannot connect to the Docker daemon` - open `Docker Desktop` - Kotlin/Js or Kotlin/Wasm - `kotlinUpgradePackageLock` or `kotlinWasmUpgradePackageLock` (and also `kotlinNpmInstall` or `kotlinWasmNpmInstall`) -have a funny tendency to fail sometimes, and you don't know why. -
-I'll tell you! -
-We use proxy repos, and sometimes dependencies get downloaded from the wrong source. -Make sure ALL urls in `package-lock.json` files start with `https://packages.jetbrains.team/npm/p/krpc/build-deps/`. -
-If something doesn't work, your steps are: + have a funny tendency to fail sometimes, and you don't know why. + + I'll tell you! + + We use proxy repos, and sometimes dependencies get downloaded from the wrong source. + Make sure ALL urls in `package-lock.json` files start with `https://packages.jetbrains.team/npm/p/krpc/build-deps/`. + + If something doesn't work, your steps are: - Delete `package-lock.json` file - Delete `/build/js` / `/build/wasm` - Run `kotlinUpgradePackageLock` / `kotlinWasmUpgradePackageLock` @@ -384,13 +409,13 @@ If something doesn't work, your steps are: - `always-auth=true` - `save-exact=true` - `//packages.jetbrains.team/npm/p/krpc/build-deps/:_authToken=`, -where `` is from the [proxy-repositories.md](proxy-repositories.md) guide. + where `` is from the [proxy-repositories.md](proxy-repositories.md) guide. - Check that `/.npmrc` / `/.yarnrc` don't interfere -command to debug. Replace versions of tools if needed. + command to debug. Replace versions of tools if needed. - When you get the following error — `puppeteer` failed to run the installation script. -Reasons vary, try updating the version to a newer one, -check the [.puppeteerrc.cjs](../.puppeteerrc.cjs) and [chrome_bin.js](../karma/chrome_bin.js) files if they are valid js. - + Reasons vary, try updating the version to a newer one, + check the [.puppeteerrc.cjs](../.puppeteerrc.cjs) and [chrome_bin.js](../karma/chrome_bin.js) files if they are valid js. + For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. at ChromeLauncher.resolveExecutablePath (/rpc/build/js/packages/kotlinx-rpc-utils-test/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:295:27) @@ -410,27 +435,33 @@ check the [.puppeteerrc.cjs](../.puppeteerrc.cjs) and [chrome_bin.js](../karma/c } } This means the `puppeteer` failed to locate Chrome. -Either the cache dir is wrong (check [.puppeteerrc.cjs](../.puppeteerrc.cjs) file) or it really isn't there. -
-Reasons again vary. -When `npm` installs `puppeteer`, it should execute script to install the browser too -(On CI to the `/.puppeteer/browsers` directory). -This absence may be caused by the `--ignore-scripts` flag. -Check the clean installation (`rm -rf build && ./gradlew clean cleanJsBrowserTest`) with `--debug` flag. -(Something like `./gradlew jsBrowserTest --debug`). -**IMPORTANT: run in docker with `TEAMCITY_VERSION` env var set, if you are chasing a CI fail**. -
-The property is set in [npm.kt](../gradle-conventions/src/main/kotlin/util/tasks/npm.kt), see `ignoreScripts`, -it should be `false`. -
-If this is not the case, check the debug log for other `node`-related issues. -Try installing browsers manually: `~/.gradle/nodejs/node-v22.0.0-linux-x64/bin/node build/js/node_modules/puppeteer/install.mjs` -If this works — problem is somewhere in KGP and probably your configs. -Check that your config (like ones with `ignoreScript`) are actually applied, -as they use on demand execution and may target wrong plugin or extension and never be executed. -
-**Bonus**: it may not be installed, because npm install doesn't do this. -See the long comment in [npm.kt](../gradle-conventions/src/main/kotlin/util/tasks/npm.kt). + Either the cache dir is wrong (check [.puppeteerrc.cjs](../.puppeteerrc.cjs) file) or it really isn't there. + + Reasons again vary. + + - When `npm` installs `puppeteer`, it should execute script to install the browser too + (On CI to the `/.puppeteer/browsers` directory). + This absence may be caused by the `--ignore-scripts` flag. + + Check the clean installation (`rm -rf build && ./gradlew clean cleanJsBrowserTest`) with `--debug` flag. + (Something like `./gradlew jsBrowserTest --debug`). + + The property is set in [npm.kt](../gradle-conventions/src/main/kotlin/util/tasks/npm.kt), see `ignoreScripts`, + it should be `false`. + + **IMPORTANT: run in docker with `TEAMCITY_VERSION` env var set, if you are chasing a CI fail**. + + - If this is not the case, check the debug log for other `node`-related issues. + Try installing browsers manually: + + ~/.gradle/nodejs/node-v22.0.0-linux-x64/bin/node build/js/node_modules/puppeteer/install.mjs + + If this works — problem is somewhere in KGP and probably your configs. + Check that your config (like ones with `ignoreScript`) are actually applied, + as they use on demand execution and may target wrong plugin or extension and never be executed. + + **Bonus**: it may not be installed, because npm install doesn't do this. + See the long comment in [npm.kt](../gradle-conventions/src/main/kotlin/util/tasks/npm.kt). Something doesn't work, and you are sure it's not your fault? Report it appropriately! Don't be lazy. diff --git a/gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts b/gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts index f7c468fb4..0a8983449 100644 --- a/gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts +++ b/gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ @file:Suppress("DuplicatedCode") diff --git a/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts b/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts index fde346887..7ac25500f 100644 --- a/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts +++ b/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts @@ -2,86 +2,32 @@ * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import util.* -import util.other.DirectoryNames -import java.nio.file.Files -import java.nio.file.Path -import kotlin.text.lowercase +import gradle.kotlin.dsl.accessors._46680087f5e33e6a2d850d9e9b86aaa7.main +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import util.csm.ProcessCsmTemplate +import util.other.libs +import kotlin.io.path.createDirectories -val kotlinCompilerVersion: KotlinVersion by extra +val kotlin = the() -fun NamedDomainObjectContainer.applyCompilerSpecificSourceSets() { - forEach { set -> - val sourceDirs = set.kotlin.sourceDirectories.toList() - val path = sourceDirs.firstOrNull() // one is ok in most cases because we need its parent directory - ?: error( - "Expected at least one source set dir for '${set.name}' source set (kotlin dir). " + - "Review the case and adjust the script" - ) - - val sourceSetPath = path.toPath().parent - if (!Files.exists(sourceSetPath)) { - return@forEach - } - - val core = sourceSetPath.resolve(DirectoryNames.CORE_SOURCE_DIR).toFile() - - // version-specific source sets - val vsSets = filterSourceDirsForCSM(sourceSetPath) - - // choose 'latest' if there are no more specific ones - val mostSpecificApplicable = vsSets.mostSpecificVersionOrLatest(kotlinCompilerVersion) - - logger.lifecycle( - "${project.name}: included version specific source sets: " + - "[${core.name}${mostSpecificApplicable?.let { ", ${it.name}" } ?: ""}]" - ) - - val newSourceDirectories = listOfNotNull(core, mostSpecificApplicable) - - set.kotlin.setSrcDirs(newSourceDirectories) // 'core' source set instead of 'kotlin' - - set.configureResources(sourceSetPath) - - val excluded = vsSets.filter { it != mostSpecificApplicable } - logger.lifecycle( - "${project.name}: excluded version specific source sets: [${excluded.joinToString { it.name }}]" - ) - } +val templatesDir = kotlin.sourceSets.main.map { + it.kotlin.srcDirs.single { dir -> dir.name == "kotlin" }.toPath().parent.resolve("templates") } -fun KotlinSourceSet.configureResources(sourceSetPath: Path) { - val parent = sourceSetPath.parent.toAbsolutePath() - if (!Files.exists(parent)) { - error("Expected parent dir for ${sourceSetPath.toAbsolutePath()}") - } - - // only works for jvm projects - val resourcesName = if (name.lowercase().contains(DirectoryNames.MAIN_SOURCE_SET)) { - DirectoryNames.MAIN_RESOURCES - } else { - DirectoryNames.TEST_RESOURCES - } - - val resourcesDir = parent.resolve(resourcesName) - - if (!Files.exists(resourcesDir)) { - return - } +templatesDir.get().createDirectories() - val mostSpecificApplicable = filterSourceDirsForCSM(resourcesDir) - .mostSpecificVersionOrLatest(kotlinCompilerVersion) - - val versionNames = listOfNotNull(DirectoryNames.CORE_SOURCE_DIR, mostSpecificApplicable?.name) - - resources.srcDirs(versionNames.map { resourcesDir.resolve(it).toFile() }) +val sourcesDir = project.layout.buildDirectory.asFile.map { + it.toPath().resolve("generated-sources/csm") } -withKotlinJvmExtension { - sourceSets.applyCompilerSpecificSourceSets() -} +val processCsmTemplates = + tasks.register( + "processCsmTemplates", + libs.versions.kotlin.compiler.get(), + templatesDir, + sourcesDir, + ) -withKotlinKmpExtension { - sourceSets.applyCompilerSpecificSourceSets() +kotlin.sourceSets.main { + kotlin.srcDirs(processCsmTemplates.map { it.sourcesDir }) } diff --git a/gradle-conventions/src/main/kotlin/util/csm/task.kt b/gradle-conventions/src/main/kotlin/util/csm/task.kt new file mode 100644 index 000000000..881d50c81 --- /dev/null +++ b/gradle-conventions/src/main/kotlin/util/csm/task.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package util.csm + +import org.gradle.api.DefaultTask +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.TaskAction +import java.nio.file.Path +import javax.inject.Inject +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.exists +import kotlin.io.path.isDirectory +import kotlin.io.path.readLines +import kotlin.io.path.walk +import kotlin.io.path.writeLines + +abstract class ProcessCsmTemplate @Inject constructor( + @get:Input val kotlinComplierVersion: String, + @get:InputDirectory val templatesDir: Provider, + @get:OutputDirectory val sourcesDir: Provider, +) : DefaultTask() { + @OptIn(ExperimentalPathApi::class) + @TaskAction + fun process() { + val templates = templatesDir.get() + if (!templates.exists()) { + return + } + + val sources = sourcesDir.get() + + templates.walk().forEach { file -> + if (file.isDirectory()) { + return@forEach + } + + val out = sources.resolve(templates.relativize(file)) + val lines = CsmTemplateProcessor.process( + lines = file.readLines(Charsets.UTF_8), + kotlinCompilerVersion = kotlinComplierVersion, + logger = logger, + ) + out.parent.toFile().mkdirs() + out.writeLines(lines, charset = Charsets.UTF_8) + } + } +} diff --git a/gradle-conventions/src/main/kotlin/util/csm/template.kt b/gradle-conventions/src/main/kotlin/util/csm/template.kt new file mode 100644 index 000000000..cbab27b58 --- /dev/null +++ b/gradle-conventions/src/main/kotlin/util/csm/template.kt @@ -0,0 +1,181 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package util.csm + +import org.gradle.api.GradleException +import org.slf4j.Logger + +object CsmTemplateProcessor { + fun process(lines: List, kotlinCompilerVersion: String, logger: Logger): List { + val result = mutableListOf() + + val tags: ArrayDeque = ArrayDeque() + var section: String? = null + var default = false + var specific: Specific? = null + var matchedSpecific = false + var matchedDefault = false + + val defaultBuffer = mutableListOf() + val specificBuffer = mutableListOf() + + lines.forEachIndexed { i, line -> + val trimmed = line.trim() + when { + trimmed.startsWith("//##csm") -> { + val header = trimmed.removePrefix("//##csm").trim() + val name = header.substringBefore("=") + + if (name.startsWith("/")) { + val latest = tags.firstOrNull() + if (latest == null || name != "/$latest") { + throw GradleException("Expected tag '$latest' in csm header, but got '$name': $i >> $line") + } + + tags.removeFirst() + + when { + name == "/default" -> default = false + name == "/specific" -> specific = null + section != null && name == "/$section" -> { + when { + matchedSpecific -> { + result += specificBuffer + } + + matchedDefault -> { + logger.info("[CSM] Matched default for $section") + result += defaultBuffer + } + } + + matchedSpecific = false + specificBuffer.clear() + + matchedDefault = false + defaultBuffer.clear() + + section = null + } + + else -> throw GradleException("Unexpected tag in csm header '$name'. Expected $section: $i >> $line") + } + } else { + when { + default && name == "default" -> { + throw GradleException("Nested 'default' tag in csm header: $i >> $line") + } + + specific != null && name == "specific" -> { + throw GradleException("Nested 'specific' tag in csm header: $i >> $line") + } + + section != null && name == section -> { + throw GradleException("Nested '$section' tag in csm header: $i >> $line") + } + } + + tags.addFirst(name) + + when (name) { + "default" -> { + if (matchedDefault) { + throw GradleException("Multiple 'default' tags in csm header: $i >> $line") + } + + matchedDefault = true + + default = true + } + + "specific" -> { + val pattern = header.substringAfter("=") + .removePrefix("[") + .removeSuffix("]") + .takeIf { it.isNotEmpty() } + ?: throw GradleException("Expected pattern in csm header 'specific': $i >> $line") + + specific = if (!matchedSpecific && matchesKotlinVersion(kotlinCompilerVersion, pattern)) { + logger.info("[CSM] Matched specific '$pattern' for $section") + matchedSpecific = true + + Specific.Apply + } else { + Specific.Skip + } + } + + else -> section = name + } + } + } + + section != null && !default && specific == null -> { + throw GradleException("Expected 'default' or 'specific' tag before code in '$section' tag: $i >> $line") + } + + section == null -> { + result += line + } + + default -> { + defaultBuffer += line + } + + specific == Specific.Apply -> { + specificBuffer += line + } + + specific == Specific.Skip -> {} + } + } + + return result + } + + private fun matchesKotlinVersion(projectVersion: String, pattern: String): Boolean { + return pattern.split(",").any { part -> + if (part.contains("...")) { + val (from, to) = part + .split("...") + + if (from.contains("*")) { + throw GradleException("Wildcard is not allowed in 'from' part of kotlin version range: $from, $pattern") + } + + if (to.contains("-") || to.contains("-")) { + throw GradleException("Non stable versions are not allowed in kotlin version range: $pattern") + } + + val fromV = KotlinVersion.parse(from) + val toV = KotlinVersion.parse(to) + val projectV = KotlinVersion.parse(projectVersion) + + projectV in fromV..toV + } else { + val prefix = part.trim().substringBefore("*") + projectVersion.startsWith(prefix) + } + } + } + + private fun KotlinVersion.Companion.parse(string: String): KotlinVersion { + val version = string + .substringBefore("-") + .replace("*", "${KotlinVersion.MAX_COMPONENT_VALUE}") + .split(".") + .map { it.toInt() } + + val major = version.getOrNull(0) ?: throw GradleException("Expected major version in kotlin version range: $string") + val minor = version.getOrNull(1) ?: KotlinVersion.MAX_COMPONENT_VALUE + val patch = version.getOrNull(2) ?: KotlinVersion.MAX_COMPONENT_VALUE + + return KotlinVersion(major, minor, patch) + } + + private enum class Specific { + Skip, Apply; + } +} diff --git a/gradle-conventions/src/main/kotlin/util/kotlinVersion.kt b/gradle-conventions/src/main/kotlin/util/kotlinVersion.kt index cb0100d00..a04f9e306 100644 --- a/gradle-conventions/src/main/kotlin/util/kotlinVersion.kt +++ b/gradle-conventions/src/main/kotlin/util/kotlinVersion.kt @@ -8,12 +8,6 @@ import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.provideDelegate import util.other.ActionApplied -import util.other.DirectoryNames -import util.other.filterDirectory -import util.other.name -import java.io.File -import java.nio.file.Files -import java.nio.file.Path fun String.kotlinVersionParsed(): KotlinVersion { val (major, minor, patch) = substringBefore('-').split(".").map { it.toInt() } @@ -37,77 +31,3 @@ inline fun ExtensionAware.whenKotlinCompilerIsAtLeast( return ActionApplied.NotApplied } - -fun filterSourceDirsForCSM(sourceSetPath: Path): List { - return filterDirectory(sourceSetPath) { - Files.isDirectory(it) && it.name().matches(directoryNameRegex) - } -} - -fun Collection.mostSpecificVersionOrLatest(kotlinVersion: KotlinVersion): File? { - return mostSpecificByVersionOrNull(kotlinVersion) - ?: singleOrNull { it.name == DirectoryNames.LATEST_SOURCE_DIR } -} - - - -// Versioning is used to sort version-specific source sets in the 'first comes more specific' order -// By 'more specific' we mean that '1.7.10' is more specific than '1.7'. -// So [1.7, 1.7.10, 1.9.10, 1.7.22, 1.9, 1, 1.7.0, latest, 1.8] -// will be sorted as [1.7.0, 1.7.10, 1.7.22, 1.7, 1.8, 1.9.10, 1.9, 1, latest] -// It's ok to have version '1'. -// For example, we may have '1.7' and '1' specific source sets. -// That would mean that all 1.7.* versions we compile with the '1.7' source set, -// and 1.8.+ up to 1.9.25 will be with the '1' source set -private class CompilerModuleVersion(fullName: String, prefix: String) : Comparable { - // For example, "v_1_7_10" -> "1.7.10" - val version = fullName - .removePrefix(prefix) - .replace('_', '.') - - val kotlin by lazy { - val parts = version.split('.') - .map { it.toInt() } - - KotlinVersion(parts[0], parts.getOrNull(1) ?: 0, parts.getOrNull(2) ?: 0) - } - - override fun compareTo(other: CompilerModuleVersion): Int { - return when { - version.length == other.version.length -> version.compareTo(other.version) - version.length < other.version.length -> 1 - else -> -1 - } - } -} - -private fun Collection.sortAndSelectBySemVer( - prefix: String, - selector: (CompilerModuleVersion) -> Boolean, -): File? { - return filter { it.name.startsWith(prefix) } - .map { it to CompilerModuleVersion(it.name, prefix) } - .sortedBy { (_, semVer) -> semVer } - .firstOrNull { (_, semVer) -> selector(semVer) } - ?.first -} - -private fun Collection.mostSpecificByVersionOrNull(kotlinVersion: KotlinVersion): File? { - val (vPrefixed, prePrefixed) = partition { it.name.startsWith("v_") } - - return vPrefixed.sortAndSelectBySemVer("v_") { semVer -> - kotlinVersion.toString().startsWith(semVer.version) - } ?: prePrefixed.sortAndSelectBySemVer("pre_") { semVer -> - kotlinVersion <= semVer.kotlin - } -} - -// matches: -// - latest -// - v_1 -// - v_1_9 -// - v_1_9_2 -// - v_1_9_24 -// - pre_1_9_20 -// etc. -private val directoryNameRegex = "^(latest|(v|pre)(_\\d){1,3}\\d?)$".toRegex() diff --git a/krpc/krpc-test/src/commonTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.kt b/krpc/krpc-test/src/commonTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.kt index 88ab602b4..5f4e6d487 100644 --- a/krpc/krpc-test/src/commonTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.kt +++ b/krpc/krpc-test/src/commonTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.kt @@ -77,7 +77,7 @@ class TransportTest { } private fun runTest(block: suspend TestScope.() -> Unit): TestResult = - kotlinx.coroutines.test.runTest(timeout = 15.seconds) { + kotlinx.coroutines.test.runTest(timeout = 20.seconds) { debugCoroutines() val logger = RpcInternalCommonLogger.logger("TransportTest") diff --git a/updateSitemap.sh b/updateSitemap.sh index 39fab7816..1e111ee0d 100755 --- a/updateSitemap.sh +++ b/updateSitemap.sh @@ -32,7 +32,7 @@ current_date=$(date +%Y-%m-%d) temp_file=$(mktemp) # Extract the first line from sitemap file (XML header), removing closing urlset tag if present -head -n 1 "$sitemap_file" | sed -En 's/<\/urlset>//' > "$temp_file" +head -n 1 "$sitemap_file" | sed -En 's/<\/urlset>//p' > "$temp_file" # Find all HTML files in the API docs directory recursively find "$api_docs_dir" -type f -name "*.html" | while read -r html_file; do