File tree Expand file tree Collapse file tree 5 files changed +121
-0
lines changed
kotlin-analysis-api/src/test/kotlin/com/google/devtools/ksp/test
src/main/kotlin/com/google/devtools/ksp/processor Expand file tree Collapse file tree 5 files changed +121
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,18 @@ class KSPAATest : AbstractKSPAATest() {
145
145
runTest(" ../test-utils/testData/api/builtInTypes.kt" )
146
146
}
147
147
148
+ @TestMetadata(" A.kt" )
149
+ @Test
150
+ fun testA () {
151
+ runTest(" ../test-utils/testData/api/A.kt" )
152
+ }
153
+
154
+ @TestMetadata(" B.kt" )
155
+ @Test
156
+ fun testB () {
157
+ runTest(" ../test-utils/testData/api/B.kt" )
158
+ }
159
+
148
160
@Disabled
149
161
@TestMetadata(" checkOverride.kt" )
150
162
@Test
Original file line number Diff line number Diff line change
1
+ package com.google.devtools.ksp.processor
2
+
3
+ import com.google.devtools.ksp.KspExperimental
4
+ import com.google.devtools.ksp.getClassDeclarationByName
5
+ import com.google.devtools.ksp.getDeclaredProperties
6
+ import com.google.devtools.ksp.processing.Resolver
7
+ import com.google.devtools.ksp.symbol.KSAnnotated
8
+
9
+ open class AProcessor : AbstractTestProcessor () {
10
+ val results = mutableListOf<String >()
11
+ override fun toResult (): List <String > {
12
+ return results
13
+ }
14
+
15
+ @OptIn(KspExperimental ::class )
16
+ override fun process (resolver : Resolver ): List <KSAnnotated > {
17
+ resolver.getClassDeclarationByName(" BaseClass" )!! .let { cls ->
18
+ println (cls.getDeclaredProperties().map { " ${it.simpleName.asString()} (${it.hasBackingField} )" }.toList())
19
+ }
20
+ return emptyList()
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ package com.google.devtools.ksp.processor
2
+
3
+ import com.google.devtools.ksp.KspExperimental
4
+ import com.google.devtools.ksp.getClassDeclarationByName
5
+ import com.google.devtools.ksp.getDeclaredProperties
6
+ import com.google.devtools.ksp.processing.Resolver
7
+ import com.google.devtools.ksp.symbol.KSAnnotated
8
+
9
+ open class BProcessor : AbstractTestProcessor () {
10
+ val results = mutableListOf<String >()
11
+ override fun toResult (): List <String > {
12
+ return results
13
+ }
14
+
15
+ @OptIn(KspExperimental ::class )
16
+ override fun process (resolver : Resolver ): List <KSAnnotated > {
17
+ resolver.getClassDeclarationByName(" BaseClass" )!! .let { cls ->
18
+ println (cls.getDeclaredProperties().map { " ${it.simpleName.asString()} (${it.hasBackingField} )" }.toList())
19
+ // `hasBackingField` is true when running the test individually but is false when running the whole KSPAATest.
20
+ }
21
+ return emptyList()
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2020 Google LLC
3
+ * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ // WITH_RUNTIME
19
+ // TEST PROCESSOR: AProcessor
20
+ // EXPECTED:
21
+ // END
22
+ // MODULE: lib
23
+ // FILE: Test.kt
24
+ open class BaseClass <T >(val genericProp : T ) {
25
+ fun baseMethod (input : T ) {}
26
+ }
27
+ class SubClass (x : Int ) : BaseClass<Int>(x) {
28
+ val subClassProp : String = " abc"
29
+ }
30
+ // MODULE: main(lib)
31
+ // FILE: Main.kt
32
+ class Main
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2020 Google LLC
3
+ * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ // WITH_RUNTIME
19
+ // TEST PROCESSOR: BProcessor
20
+ // EXPECTED:
21
+ // END
22
+ // MODULE: lib
23
+ // FILE: Test.kt
24
+ open class BaseClass (
25
+ open val value : List <Int >
26
+ )
27
+ class SubClass (
28
+ override val value : MutableList <Int >
29
+ ) : BaseClass(value)
30
+ // MODULE: main(lib)
31
+ // FILE: Main.kt
32
+ class Main
You can’t perform that action at this time.
0 commit comments