Skip to content

Commit a7a2754

Browse files
yigittschuchortdev
authored andcommitted
repro find annotations bug
1 parent 4125e75 commit a7a2754

File tree

1 file changed

+37
-0
lines changed
  • ksp/src/test/kotlin/com/tschuchort/compiletesting

1 file changed

+37
-0
lines changed

ksp/src/test/kotlin/com/tschuchort/compiletesting/KspTest.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,43 @@ class KspTest {
159159
)
160160
}
161161

162+
@Test
163+
fun canFindSymbols() {
164+
val javaSource = SourceFile.java(
165+
"JavaSubject.java",
166+
"""
167+
@${SuppressWarnings::class.qualifiedName}("")
168+
class JavaSubject {}
169+
""".trimIndent()
170+
)
171+
val kotlinSource = SourceFile.kotlin(
172+
"KotlinSubject.kt",
173+
"""
174+
@${SuppressWarnings::class.qualifiedName}("")
175+
class KotlinSubject {}
176+
""".trimIndent()
177+
)
178+
val result = mutableListOf<String>()
179+
val processor = object: AbstractTestSymbolProcessor() {
180+
override fun process(resolver: Resolver) {
181+
resolver.getSymbolsWithAnnotation(
182+
SuppressWarnings::class.java.canonicalName
183+
).filterIsInstance<KSClassDeclaration>()
184+
.forEach{
185+
result.add(it.qualifiedName!!.asString())
186+
}
187+
}
188+
}
189+
val compilation = KotlinCompilation().apply {
190+
sources = listOf(javaSource, kotlinSource)
191+
symbolProcessors += processor
192+
}
193+
compilation.compile()
194+
assertThat(result).containsExactly(
195+
"JavaSubject", "KotlinSubject"
196+
)
197+
}
198+
162199
internal open class ClassGeneratingProcessor(
163200
private val packageName: String,
164201
private val className: String

0 commit comments

Comments
 (0)