I swear I saw somewhere an annotation/comment inje...
# intellij
m
I swear I saw somewhere an annotation/comment injection where I could tell IntelliJ some String is a path to an actual File and IntelliJ would show me a warning/error if the file did not exist. Does that ring a bell to anyone? I can't find it anymore. Did I just dream it?
s
Copy code
@Language("file-reference")
😍 1
thank you color 1
I'm not sure why a file reference is a "language" 😄
m
Aaaahhhh thank you so much! 🙏
Is there a list of supported languages somewhere?
s
If you have the cursor over a String and use Alt+Enter for the context actions menu, you can choose "Inject language or reference" and you'll get a list. Immediately after choosing one, if you press Alt+Enter again, it'll add the relevant annotation.
❤️ 1
I don't know of anywhere else the list of choices is documented, though
m
This is perfect 👌 Thanks again!
f
Is this annotation not available in AS? I can't seem to use it even when including the jetbrains annotation lib.
m
@Fergus Hewson it should be there (but it’s not KMP)
f
Ah that is my problem 🙂 Thanks @mbonnin
a
version 25.0.0 should support KMP 🤞 https://github.com/JetBrains/java-annotations/releases/tag/25.0.0 (Although I tried it and encountered problems in non-JVM targets)
👀 2
🚀 1
c
When the annotation doesn't work, you can use a comment instead:
Copy code
// language=file-reference
very nice 4