[java-injection] Support annotations on methods returning template processor (IDEA-333006)

GitOrigin-RevId: e08169d48cbd23db8cfaf2ee4466037bb70a2219
This commit is contained in:
Tagir Valeev
2024-01-26 14:57:40 +00:00
committed by intellij-monorepo-bot
parent 877c44411b
commit ac4072eda4
2 changed files with 13 additions and 6 deletions
@@ -256,16 +256,19 @@ class JavaLanguageInjectionSupportTest : AbstractLanguageInjectionTestCase() {
class Hello {
void test(@Subst("ClassName") String name, String message) {
@Language("JAVA")
String s = STR.""${'"'}
String s = javaProcessor().""${'"'}
class \{name} {
void main() {
System.out.println("\{message}");
}
}""${'"'};
}
}
""".trimIndent())
@Language("JAVA")
private static StringTemplate.Processor<String, RuntimeException> javaProcessor() {
return STR;
}
}""".trimIndent())
myFixture.checkHighlighting()
injectionTestFixture.assertInjectedContent("""
class ClassName {
@@ -156,8 +156,12 @@ public final class AnnotationUtilEx {
PsiElement target = ref.resolve();
if (target instanceof PsiVariable var) {
visitor.visitVariable(var);
} else if (target instanceof PsiMethod method) {
visitor.visitMethodReturnStatement(parent, method);
}
}
else if (templ.getProcessor() instanceof PsiCallExpression call && call != element) {
PsiMethod method = call.resolveMethod();
if (method != null) {
visitor.visitMethodReturnStatement(call, method);
}
}
}