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
7
7
plugins {
8
8
alias(libs.plugins.conventions.jvm)
9
9
alias(libs.plugins.compiler.specific.module)
10
+ alias(libs.plugins.conventions.no.psi.element)
10
11
}
11
12
12
13
kotlin {
Original file line number Diff line number Diff line change @@ -1245,7 +1245,7 @@ internal class RpcStubGenerator(
1245
1245
val protobufMessage = owner.getAnnotation(ctx.withCodecAnnotation.owner.kotlinFqName)
1246
1246
1247
1247
return if (protobufMessage != null ) {
1248
- val classReference = protobufMessage.arguments .single() as ? IrClassReference
1248
+ val classReference = vsApi{ protobufMessage.argumentsVS } .single() as ? IrClassReference
1249
1249
? : error(" Expected IrClassReference for ${ctx.withCodecAnnotation.owner.kotlinFqName} parameter" )
1250
1250
1251
1251
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
7
7
plugins {
8
8
alias(libs.plugins.conventions.jvm)
9
9
alias(libs.plugins.compiler.specific.module)
10
+ alias(libs.plugins.conventions.no.psi.element)
10
11
}
11
12
12
13
kotlin {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
7
7
plugins {
8
8
alias(libs.plugins.conventions.jvm)
9
9
alias(libs.plugins.compiler.specific.module)
10
+ alias(libs.plugins.conventions.no.psi.element)
10
11
}
11
12
12
13
kotlin {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import util.whenKotlinCompilerIsAtLeast
10
10
plugins {
11
11
alias(libs.plugins.conventions.jvm)
12
12
alias(libs.plugins.compiler.specific.module)
13
+ alias(libs.plugins.conventions.no.psi.element)
13
14
}
14
15
15
16
tasks.jar {
Original file line number Diff line number Diff line change @@ -57,13 +57,14 @@ object FirWithCodecDeclarationChecker {
57
57
58
58
val codecTargetClass = codecClassSymbol.findMessageCodecSuperType(context.session)
59
59
.typeArguments.first().type
60
+ ? : error(" Unexpected unresolved type argument for @WithCodec annotation" )
60
61
61
- if (codecTargetClass? .classId != declaration.symbol.classId) {
62
+ if (codecTargetClass.classId != declaration.symbol.classId) {
62
63
reporter.reportOn(
63
64
source = withCodec.findArgumentByName(CODEC_ARGUMENT_NAME )?.source,
64
65
factory = FirGrpcDiagnostics .CODEC_TYPE_MISMATCH ,
65
66
a = declaration.symbol.defaultType(),
66
- b = kClassValue ,
67
+ b = codecTargetClass ,
67
68
context = context,
68
69
)
69
70
}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fun registerDiagnosticRendererFactories() {
32
32
// ##csm specific=[2.0.0...2.2.10]
33
33
RootDiagnosticRendererFactory .registerFactory(FirRpcDiagnostics .getRendererFactoryVs())
34
34
RootDiagnosticRendererFactory .registerFactory(FirRpcStrictModeDiagnostics .getRendererFactoryVs())
35
+ RootDiagnosticRendererFactory .registerFactory(FirGrpcDiagnostics .getRendererFactoryVs())
35
36
// ##csm /specific
36
37
// ##csm /registerDiagnosticRendererFactories
37
38
}
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" }
159
159
conventions-root = { id = " conventions-root" }
160
160
conventions-dokka-spec = { id = " conventions-dokka-spec" }
161
161
conventions-dokka-public = { id = " conventions-dokka-public" }
162
+ conventions-no-psi-element = { id = " conventions-no-psi-element" }
162
163
compiler-specific-module = { id = " compiler-specific-module" }
163
164
164
165
# gradle-plugin project
You can’t perform that action at this time.
0 commit comments