Make auto-completion work in Kotlin scripts with context


I work on a Kotlin project that also uses Kotlin scripts (embedded as resources). The Kotlin script files are evaluated with some context, i.e. with variables bound. As a result, the plain script does not compile / run by itself (Ctrl+Shift+10 on Windows), and either does auto-completion work.

Is there a way to tell the IDE about the context in which the script is run, i.e. which variables will be bound at runtime, so that the IDE will be able to perform auto-completion when working on the script inside the IDE?