Add ScriptExpectedLocations annotation to script-runtime.

It describes where script file can be found.
This commit is contained in:
Natalia Selezneva
2018-03-19 10:53:35 +03:00
parent 27f1eb1e13
commit 15914dac86
3 changed files with 37 additions and 0 deletions
@@ -32,6 +32,8 @@ import kotlin.reflect.full.primaryConstructor
import kotlin.script.dependencies.ScriptDependenciesResolver
import kotlin.script.experimental.dependencies.AsyncDependenciesResolver
import kotlin.script.experimental.dependencies.DependenciesResolver
import kotlin.script.experimental.location.ScriptExpectedLocations
import kotlin.script.experimental.location.ScriptExpectedLocation
import kotlin.script.templates.*
open class KotlinScriptDefinitionFromAnnotatedTemplate(
@@ -132,6 +134,12 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
}
}
override val scriptExpectedLocations: List<ScriptExpectedLocation> by lazy {
takeUnlessError {
template.annotations.firstIsInstanceOrNull<ScriptExpectedLocations>()
}?.value?.toList() ?: super.scriptExpectedLocations
}
override val name = template.simpleName!!
override fun isScript(fileName: String): Boolean =