A Kotlin language runtime module for NetKernel.
res:/experiment/one.nk.kts:
val req = context.createRequest("active:kotlin")
req.addArgument("operator", "res:/experiment/two.nk.kts")
req.addArgumentByValue("recipient", "world")
context.response(context.issueRequestForResponse(req))res:/experiment/two.nk.kts:
val recipient = context.source("arg:recipient", String::class.java)
context.response("Hello $recipient")Running active:kotlin+operator@res:/experiment/one.nk.kts will result in:
Hello world
res:/experiment/one.nk.kts:
response {
source<String>("active:kotlin") {
argument("operator", sourceRequest<Any>("res:/experiment/two.nk.kts"))
argument("recipient", "world")
}
}res:/experiment/two.nk.kts:
response {
val recipient = source<String>("arg:recipient")
"Hello $recipient"
}Running active:kotlin+operator@res:/experiment/one.nk.kts will result in:
Hello world
If you change res:/experiment/one.nk.kts to be:
response {
source<String>("active:kotlin") {
argument("operator", sourceRequest<Any>("res:/experiment/two.nk.kts"))
argument("recipient") {
sourceRequest<Any>("active:toUpper") {
argument("operand", "world")
}
}
}
}Then the result of active:kotlin+operator@res:/experiment/one.nk.kts will become:
Hello WORLD
In order to get Code Completion working correctly, you will need to:
- use
.nk.ktsas the extension for your Kotlin Script files, - have
urn.org.netkernel.lang.kotlin-1.0.0.jaras a compile dependency, - in Preferences > Build, Execution, Deployment > Compiler > Kotlin Compiler,
set the following settings in the 'Kotlin Scripting' section:
- 'Script template classes':
org.netkernel.lang.kotlin.NetKernelKotlinScript, - 'Script template classpath':
/path/to/urn.org.netkernel.lang.kotlin-1.0.0.jar.
- 'Script template classes':
- The above should lead to a row for 'NetKernel Kotlin Script' appearing in Language & Frameworks > Kotlin > Kotlin Scripting