java: track java usages of annotation methods in Unused Declaration inspection (IDEA-256632)

psi hack because UAST lacks annotation property references

GitOrigin-RevId: 9d5f2fd8e9d55584be60ca529512dd0714fb551d
This commit is contained in:
Bas Leijdekkers
2024-04-24 11:42:00 +02:00
committed by intellij-monorepo-bot
parent 45cb0ab7d0
commit 57b1788fa5
3 changed files with 31 additions and 1 deletions

View File

@@ -51,6 +51,23 @@ public final class RefJavaUtilImpl extends RefJavaUtil {
return false;
}
@Override
public boolean visitNamedExpression(@NotNull UNamedExpression node) {
PsiElement source = node.getSourcePsi();
if (source instanceof PsiNameValuePair pair) {
PsiReference reference = pair.getReference();
if (reference != null) {
PsiElement target = reference.resolve();
final RefElement refElement = refManager.getReference(target);
if (refElement != null) {
refElement.initializeIfNeeded();
refFrom.addReference(refElement, target, decl, false, true, node);
}
}
}
return false;
}
@Override
public boolean visitAnnotation(@NotNull UAnnotation node) {
PsiClass javaClass = node.resolve();