mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
committed by
intellij-monorepo-bot
parent
45cb0ab7d0
commit
57b1788fa5
+17
@@ -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();
|
||||
|
||||
@@ -25,5 +25,10 @@
|
||||
<line>25</line>
|
||||
<description>Interface is not implemented.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>RepeatableAnnotation.java</file>
|
||||
<line>41</line>
|
||||
<description>Method is never used.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
+9
-1
@@ -36,5 +36,13 @@ class Annotated1 {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
|
||||
@interface TestAnn {
|
||||
String str();
|
||||
int digit() default 2;
|
||||
}
|
||||
class Test {
|
||||
@TestAnn(str = "test")
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user