Add possibility to get location of the script.main.kts file

#KT-48414 fixed
This commit is contained in:
Alexey Subach
2021-09-19 21:53:13 +03:00
committed by Ilya Chernikov
parent 7ddf83f32d
commit ca2f37f6eb
13 changed files with 177 additions and 7 deletions
@@ -41,12 +41,14 @@ fun configureProvidedPropertiesFromJsr223Context(context: ScriptEvaluationConfig
val engineBindings = jsr223context.getBindings(ScriptContext.ENGINE_SCOPE)
val globalBindings = jsr223context.getBindings(ScriptContext.GLOBAL_SCOPE)
for (prop in knownProperties) {
val v = when {
engineBindings?.containsKey(prop.key) == true -> engineBindings[prop.key]
globalBindings?.containsKey(prop.key) == true -> globalBindings[prop.key]
else -> return ResultWithDiagnostics.Failure("Property ${prop.key} is not found in the bindings".asErrorDiagnostics())
if (prop.key !in updatedProperties) {
val v = when {
engineBindings?.containsKey(prop.key) == true -> engineBindings[prop.key]
globalBindings?.containsKey(prop.key) == true -> globalBindings[prop.key]
else -> return ResultWithDiagnostics.Failure("Property ${prop.key} is not found in the bindings".asErrorDiagnostics())
}
updatedProperties[prop.key] = v
}
updatedProperties[prop.key] = v
}
ScriptEvaluationConfiguration(context.evaluationConfiguration) {
providedProperties(updatedProperties)