Property navigation as language injection
Answered
In frameworks such as Micronaut or Spring, it's possible to find the declarations of a property inside `@Value(...)` annotations by doing "Ctrl+Click" (related issue).
I would like to achieve the same navigability behaviour with other string declarations using language injection. For example, I would like to define a constant that I pass to `@Value(...)` while still being able to find the property declaration from the constant. Micronaut example:
// language=...
public static final String myPropertyKey = "${my.property}";
@Value(myPropertyKey)
String myProperty;
However, I haven't managed to find any fitting language. Is it possible to achieve the behaviour I want using language injection? Are there any other means to achieve it?
Please sign in to leave a comment.
Hello,
Please use "Spring placeholder" as injected language.
I've just tried this snippet in both Micronaut and Spring Boot frameworks:
It should be "SpringPlaceholderReference" (not with lower case).
Thank you. IntelliJ was suggesting the lower case version when pressing "Ctrl+Space" in the `// language=` comment.
That makes it work for Spring Boot; however, it doesn't seem to make it work for Micronaut. Is there any language code counterpart to "SpringPlaceholderReference" for Micronaut?
Currently it's not supported for strings. I created feature request on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-314571/Property-navigation-from-string-literals.
Please vote for it and follow for updates.