File tree Expand file tree Collapse file tree 9 files changed +31
-3
lines changed
src/main/kotlin/kotlinx/rpc/codegen/extension
kotlin/kotlinx/rpc/codegen/checkers
templates/kotlinx/rpc/codegen/checkers/diagnostics
gradle-conventions/src/main/kotlin Expand file tree Collapse file tree 9 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -1245,7 +1245,7 @@ internal class RpcStubGenerator(
12451245 val protobufMessage = owner.getAnnotation(ctx.withCodecAnnotation.owner.kotlinFqName)
12461246
12471247 return if (protobufMessage != null ) {
1248- val classReference = protobufMessage.arguments .single() as ? IrClassReference
1248+ val classReference = vsApi{ protobufMessage.argumentsVS } .single() as ? IrClassReference
12491249 ? : error(" Expected IrClassReference for ${ctx.withCodecAnnotation.owner.kotlinFqName} parameter" )
12501250
12511251 val codec = classReference.classType
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import util.whenKotlinCompilerIsAtLeast
1010plugins {
1111 alias(libs.plugins.conventions.jvm)
1212 alias(libs.plugins.compiler.specific.module)
13+ alias(libs.plugins.conventions.no.psi.element)
1314}
1415
1516tasks.jar {
Original file line number Diff line number Diff line change @@ -57,13 +57,14 @@ object FirWithCodecDeclarationChecker {
5757
5858 val codecTargetClass = codecClassSymbol.findMessageCodecSuperType(context.session)
5959 .typeArguments.first().type
60+ ? : error(" Unexpected unresolved type argument for @WithCodec annotation" )
6061
61- if (codecTargetClass? .classId != declaration.symbol.classId) {
62+ if (codecTargetClass.classId != declaration.symbol.classId) {
6263 reporter.reportOn(
6364 source = withCodec.findArgumentByName(CODEC_ARGUMENT_NAME )?.source,
6465 factory = FirGrpcDiagnostics .CODEC_TYPE_MISMATCH ,
6566 a = declaration.symbol.defaultType(),
66- b = kClassValue ,
67+ b = codecTargetClass ,
6768 context = context,
6869 )
6970 }
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fun registerDiagnosticRendererFactories() {
3232// ##csm specific=[2.0.0...2.2.10]
3333 RootDiagnosticRendererFactory .registerFactory(FirRpcDiagnostics .getRendererFactoryVs())
3434 RootDiagnosticRendererFactory .registerFactory(FirRpcStrictModeDiagnostics .getRendererFactoryVs())
35+ RootDiagnosticRendererFactory .registerFactory(FirGrpcDiagnostics .getRendererFactoryVs())
3536// ##csm /specific
3637// ##csm /registerDiagnosticRendererFactories
3738}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+ */
4+
5+ import kotlin.io.path.readLines
6+
7+ gradle.afterProject {
8+ layout.projectDirectory.dir(" src" ).asFileTree.visit {
9+ if (isDirectory) return @visit
10+ if (file.name.endsWith(" .kt" )) {
11+ file.toPath().readLines().forEach { line ->
12+ if (! line.trim().startsWith(" //" ) && line.contains(" PsiElement" )) {
13+ throw GradleException (
14+ " Kotlin source file $file must not contain `PsiElement` reference " +
15+ " in the compiler plugin. Use KtElement instead."
16+ )
17+ }
18+ }
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ conventions-npm = { id = "conventions-npm" }
159159conventions-root = { id = " conventions-root" }
160160conventions-dokka-spec = { id = " conventions-dokka-spec" }
161161conventions-dokka-public = { id = " conventions-dokka-public" }
162+ conventions-no-psi-element = { id = " conventions-no-psi-element" }
162163compiler-specific-module = { id = " compiler-specific-module" }
163164
164165# gradle-plugin project
You can’t perform that action at this time.
0 commit comments