https://kotlinlang.org logo
m

Matthieu Stombellini

04/24/2022, 3:44 PM
Hi! For some reason, when I add a (valid)
@file:Import("somefile.main.kts")
annotation to a .main.kts script, the autocompletion and syntax highlighting on that file completely disappears (beyond very simple things like coloring keywords) after an "Apply context". Is this a known issue?
b

Big Chungus

04/24/2022, 4:05 PM
File import is very flakey I'm affraid. Try with this, though file://./somefile.kts
z

Zac Sweers

04/25/2022, 9:47 AM
using
file://
as a prefix appears to actually break it
Copy code
./slackw generate-project --help
error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/file:/project-gen-common.smain.kts (project-gen.main.kts)
tooling/scripts/kscripts/project-gen/project-gen.main.kts: error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/file:/project-gen-common.smain.kts
b

Big Chungus

04/25/2022, 9:50 AM
How did you actually put it in?
file:// is a bit iffy about slashes
z

Zac Sweers

04/25/2022, 9:50 AM
Copy code
@file:Import("file://./project-gen-common.smain.kts")
b

Big Chungus

04/25/2022, 9:50 AM
Try with one or no leading slashes instead of two
z

Zac Sweers

04/25/2022, 9:50 AM
can you write an example of what you mean?
this works but has the same lack of indexing issues
Copy code
@file:Import("./project-gen-common.smain.kts")
b

Big Chungus

04/25/2022, 9:51 AM
Well file:./local/path
Or file:/./local/path
z

Zac Sweers

04/25/2022, 9:51 AM
neither of those are valid
Copy code
✘  ~/dev/slack/slack-android-ng   z/cliktUpdates ±  ./slackw generate-project --help
error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/tooling/scripts/kscripts/project-gen/file:./project-gen-common.smain.kts (project-gen.main.kts)
tooling/scripts/kscripts/project-gen/project-gen.main.kts: error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/tooling/scripts/kscripts/project-gen/file:./project-gen-common.smain.kts
 ✘  ~/dev/slack/slack-android-ng   z/cliktUpdates ±  ./slackw generate-project --help
error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/file:/project-gen-common.smain.kts (project-gen.main.kts)
tooling/scripts/kscripts/project-gen/project-gen.main.kts: error: source file or directory not found: /Users/zacsweers/dev/slack/slack-android-ng/file:/project-gen-common.smain.kts
 ✘  ~/dev/slack/slack-android-ng   z/cliktUpdates ± 
b

Big Chungus

04/25/2022, 9:52 AM
Well, then ide is just broken I'm affraid :/
Write a script that would merge all the files into one, maybe?
z

Zac Sweers

04/25/2022, 9:52 AM
do you know of any existing bugs filed around this by chance? If not I can write one
b

Big Chungus

04/25/2022, 9:53 AM
That way you can generate a monolith for development but keep separate files for deployment
z

Zac Sweers

04/25/2022, 9:53 AM
that kind of defeats the point of file imports as a feature IMO
b

Big Chungus

04/25/2022, 9:53 AM
I think there's one already as it's not the first time people complain about it (myself included). Don't have a link, tho.
j

Javier

04/25/2022, 10:17 AM
this is working for me
image.png
image.png
but the IDE highlight breaks
3 Views