Olaf Gottschalk
02/20/2025, 9:29 AM@KotlinScript
annotation like this:
const val TRALA_FILE_EXTENSION = "trala.kts"
@KotlinScript(
displayName = "TraLa Script",
fileExtension = TRALA_FILE_EXTENSION,
compilationConfiguration = TraLaScriptConfiguration::class
)
abstract class TraLaScript
plus, there is a resource file at this location:
resources/META-INF/kotlin/script/templates/com.bmw.transformation.scripting.TraLaScript
(which is empty)
The compilation configuration looks like this:
@Suppress("JavaIoSerializableObjectMustHaveReadResolve")
object TraLaScriptConfiguration : ScriptCompilationConfiguration(
{
defaultImports(traLaDefaultImports)
ide {
acceptedLocations(ScriptAcceptedLocation.Everywhere)
}
jvm {
jvmTarget("17")
compilerOptions("-Xcontext-receivers")
}
}
)
The idea is that any project that uses my DSL library can have files anywhere (see acceptedLocations
with the extension .trala.kts
and the editor will offer syntax highlight and code completion / inspection.
This used to work. Sometimes I had to restart IntelliJ... it was never straight forward. But it worked.
Now, I cannot see any way to make the editor behave like I want. And I do not know what changed.
In projects that DEPEND on my lib (with this setup), nothing works any more.
In my library project itself, the default imports don't seem to work anymore! When I add a new file foo.trala.kts
and start typing code, it inserts import statements that it should not, because they are part of the default imports...
What am I doing wrong here? Is there any good documentation on these matters?
Thanks!
Olafilya.chernikov
03/21/2025, 1:46 PMisStandalone(false)
to your ScriptCompilationConfiguration
. Although this is an old change - scripts with definitions without it are ignored in source roots by default. So it is quite suspicious that you're seeing it only now, but maybe something else was at play. For example there is a workaround with -Xallow-any-scripts-in-source-roots
compiler flag.ilya.chernikov
03/21/2025, 1:47 PMOlaf Gottschalk
04/25/2025, 5:12 AMisStandalone(false)
but still, nothing changes. The scripts are not getting their default imports at all, they are basically completely broken in IntelliJ. I would like to open a YT issue, but can it really be I am the only one who uses this? Is there any kind of documentation I can read again, like a demo project that showcases this rather odd setup with the "magic" ScriptCompilationConfiguration
class and the magic resource file META-INF/kotlin/script/templates/...
? I would like to test that in order to even write a proper YT issue as I cannot post all of my script language code. Thanks!ilya.chernikov
04/28/2025, 9:46 AMisStandalone(false)
) is considered quite an advanced case, where you need to understand quite well how your scripts will interact with the other sources in the project.
Therefore, we hide it under the opt-ins, and thus, we hope, there are not many users who use this.
Anyway, I recommend you to file an issue as is, using just the description you gave above, and we'll test the functionality on our tests and come back to you on it later.
cc: @Vladislav KoshkinOlaf Gottschalk
05/05/2025, 11:46 AMVladislav Koshkin
05/05/2025, 11:48 AM