File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
main/kotlin/com/tschuchort/compiletesting
test/kotlin/com/tschuchort/compiletesting Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
buildscript {
2
- ext. ksp_version= ' 1.4.20-dev-experimental-20210107 '
2
+ ext. ksp_version= ' 1.4.20-dev-experimental-20210111 '
3
3
}
4
4
5
5
dependencies {
Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ import com.google.devtools.ksp.KspOptions
8
8
import com.google.devtools.ksp.processing.KSPLogger
9
9
import com.google.devtools.ksp.processing.SymbolProcessor
10
10
import com.google.devtools.ksp.processing.impl.MessageCollectorBasedKSPLogger
11
+ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
11
12
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
12
13
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
14
+ import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
13
15
import org.jetbrains.kotlin.com.intellij.mock.MockProject
14
16
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
15
17
import org.jetbrains.kotlin.config.CompilerConfiguration
@@ -159,6 +161,12 @@ private class KspCompileTestingComponentRegistrar(
159
161
it.deleteRecursively()
160
162
it.mkdirs()
161
163
}
164
+ configuration[CLIConfigurationKeys .CONTENT_ROOTS ]
165
+ ?.filterIsInstance<JavaSourceRoot >()
166
+ ?.forEach {
167
+ this .javaSourceRoots.add(it.file)
168
+ }
169
+
162
170
}.build()
163
171
164
172
// Temporary until friend-paths is fully supported https://youtrack.jetbrains.com/issue/KT-34102
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ class KspTest {
160
160
}
161
161
162
162
@Test
163
- fun canFindSymbols () {
163
+ fun findSymbols () {
164
164
val javaSource = SourceFile .java(
165
165
" JavaSubject.java" ,
166
166
"""
@@ -176,22 +176,22 @@ class KspTest {
176
176
""" .trimIndent()
177
177
)
178
178
val result = mutableListOf<String >()
179
- val processor = object : AbstractTestSymbolProcessor () {
179
+ val processor = object : AbstractTestSymbolProcessor () {
180
180
override fun process (resolver : Resolver ) {
181
181
resolver.getSymbolsWithAnnotation(
182
182
SuppressWarnings ::class .java.canonicalName
183
183
).filterIsInstance<KSClassDeclaration >()
184
- .forEach{
185
- result.add(it.qualifiedName!! .asString())
186
- }
184
+ .forEach {
185
+ result.add(it.qualifiedName!! .asString())
186
+ }
187
187
}
188
188
}
189
189
val compilation = KotlinCompilation ().apply {
190
190
sources = listOf (javaSource, kotlinSource)
191
191
symbolProcessors + = processor
192
192
}
193
193
compilation.compile()
194
- assertThat(result).containsExactly (
194
+ assertThat(result).containsExactlyInAnyOrder (
195
195
" JavaSubject" , " KotlinSubject"
196
196
)
197
197
}
You can’t perform that action at this time.
0 commit comments