Add ScriptExpectedLocations annotation to script-runtime.
It describes where script file can be found.
This commit is contained in:
+8
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user