File tree Expand file tree Collapse file tree 5 files changed +15
-6
lines changed
main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin
test/kotlin/com/google/devtools/ksp/test
test-utils/src/main/kotlin/com/google/devtools/ksp/processor Expand file tree Collapse file tree 5 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,8 @@ internal fun KtAnnotated.annotations(
323323 parent : KSNode ? = null,
324324 candidates : List <KaAnnotation > = kaAnnotated.annotations
325325): Sequence <KSAnnotation > {
326+ if (candidates.isEmpty())
327+ return emptySequence()
326328 return annotationEntries.filter { ! it.isUseSiteTargetAnnotation() }.asSequence().map { annotationEntry ->
327329 KSAnnotationImpl .getCached(annotationEntry, parent) {
328330 candidates.single { it.psi == annotationEntry }
Original file line number Diff line number Diff line change @@ -97,13 +97,13 @@ class KSPAATest : AbstractKSPAATest() {
9797 @TestMetadata(" annotationValue_java.kt" )
9898 @Test
9999 fun testAnnotationValue_java () {
100- runTest(" ../kotlin-analysis-api/testData/annotationValue/java .kt" )
100+ runTest(" ../kotlin-analysis-api/testData/annotationValue/annotationValue_java .kt" )
101101 }
102102
103103 @TestMetadata(" annotationValue_kt.kt" )
104104 @Test
105105 fun testAnnotationValue_kt () {
106- runTest(" ../kotlin-analysis-api/testData/annotationValue/kotlin .kt" )
106+ runTest(" ../kotlin-analysis-api/testData/annotationValue/annotationValue_kt .kt" )
107107 }
108108
109109 @TestMetadata(" annotationWithArrayValue.kt" )
File renamed without changes.
Original file line number Diff line number Diff line change @@ -106,6 +106,8 @@ fun Fun() {
106106 class Local
107107}
108108
109+ data class DataClass
110+
109111// FILE: JavaEnum.java
110112
111113enum JavaEnum { ONE , TWO , THREE }
Original file line number Diff line number Diff line change @@ -19,10 +19,7 @@ package com.google.devtools.ksp.processor
1919
2020import com.google.devtools.ksp.getClassDeclarationByName
2121import com.google.devtools.ksp.processing.Resolver
22- import com.google.devtools.ksp.symbol.KSAnnotated
23- import com.google.devtools.ksp.symbol.KSType
24- import com.google.devtools.ksp.symbol.KSValueArgument
25- import com.google.devtools.ksp.symbol.KSVisitorVoid
22+ import com.google.devtools.ksp.symbol.*
2623
2724class AnnotationArgumentProcessor : AbstractTestProcessor () {
2825 val results = mutableListOf<String >()
@@ -37,6 +34,14 @@ class AnnotationArgumentProcessor : AbstractTestProcessor() {
3734 }
3835 }
3936
37+ resolver.getClassDeclarationByName(" DataClass" )?.let { cls ->
38+ cls.declarations.filterIsInstance<KSFunctionDeclaration >().single {
39+ it.simpleName.asString() == " copy"
40+ }.annotations.forEach {
41+ it.arguments
42+ }
43+ }
44+
4045 resolver.getSymbolsWithAnnotation(" Bar" , true ).forEach {
4146 it.annotations.forEach { it.arguments.forEach { it.accept(visitor, Unit ) } }
4247 }
You can’t perform that action at this time.
0 commit comments