I like how I am able to jump to a method when usin...
# intellij
r
I like how I am able to jump to a method when using JUnit's MethodSource, is there a way to define the same behaviour for a custom annotation, also requiring a method name?
not kotlin but kotlin colored 1
r
thanks for the pointer
e
Dont think the issue is necessary, this is built into IDE as language injection. Inject language on your annotation string parameter and use method reference
r
can you point me to something how
Inject language on your annotation string parameter and use method reference
can be done?
e
I assume they mean something like
Copy code
annotation class MySource(
    @Language("java")
    val method: String,
)

@MySource("com.example.Something::somehow")
but in any case, the IDE integration isn't a JUnit issue
e
Copy code
internal annotation class InternalMediaApi(
  @Language("jvm-method-name") val string: String = ""
)
👍 1
e
if you want it to work a specific different way, you can write your own intellij plugin
r
nice, glad I asked, the @Language annotation solved my issue nicely 🙂
@efemoney do you know by chance if there is a workaround so that the
@Language
annotation works across dependencies? I.e. I would like to use my custom annotation in another projects where the custom annotation is defined as dependency
e
The Language annotation is part of intellij annotations artifact (just ask AI for the GAV coordinates and use the latest version), you can add it as a dependency just like your annotation module, or make your annotation module depend on it so that its automatic for consumers
r
that's not the problem, the problem is that the @Language I define in project A is completely ignored by intellij in project B
e
Interesting, I havent faced that issue before
r
that's a pity, you have been my last hope 😆
😄 1
same behaviour if you use it in a kotlin/java mixed project, works in kotlin but not in java. As a workaround I create the same annotation in java as well (different package of course). Quite cumbersome