minor: rename depends annotation in script tests, add it to implicit imports

This commit is contained in:
Ilya Chernikov
2016-06-29 12:17:29 +02:00
parent 2ca4d635ea
commit 4cd8101bad
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
// this script expected parameter num : Int
@file:org.jetbrains.kotlin.scripts.depends("@{runtime}")
@file:DependsOn("@{runtime}")
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
@@ -122,7 +122,7 @@ class TestKotlinScriptDependenciesResolver : AnnotationBasedScriptDependenciesRe
private val kotlinPaths by lazy { PathUtil.getKotlinPathsForCompiler() }
@AcceptedAnnotations(depends::class)
@AcceptedAnnotations(DependsOn::class)
override fun resolve(scriptFile: File?,
annotations: Iterable<Annotation>,
environment: Map<String, Any?>?,
@@ -131,13 +131,14 @@ class TestKotlinScriptDependenciesResolver : AnnotationBasedScriptDependenciesRe
{
val cp = annotations.flatMap {
when (it) {
is depends -> listOf(if (it.path == "@{runtime}") kotlinPaths.runtimePath else File(it.path))
is DependsOn -> listOf(if (it.path == "@{runtime}") kotlinPaths.runtimePath else File(it.path))
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${it.name}", it.error)
else -> throw Exception("Unknown annotation ${it.javaClass}")
}
}
return object : KotlinScriptExternalDependencies {
override val classpath: Iterable<File> = classpathFromClassloader() + cp
override val imports: Iterable<String> = listOf("org.jetbrains.kotlin.scripts.DependsOn")
}
}
@@ -165,4 +166,4 @@ abstract class ScriptWithBaseClass(num: Int, passthrough: Int) : TestDSLClassWit
@Target(AnnotationTarget.FILE)
@Retention(AnnotationRetention.RUNTIME)
annotation class depends(val path: String)
annotation class DependsOn(val path: String)