Class AnnotationFieldReferenceFinder

java.lang.Object
org.sonar.plugins.java.api.tree.BaseTreeVisitor
org.sonar.java.checks.unused.utils.AnnotationFieldReferenceFinder
All Implemented Interfaces:
TreeVisitor

public class AnnotationFieldReferenceFinder extends BaseTreeVisitor
Finds usages of fields inside annotations. I.e. currently it is used in UnusedPrivateFieldCheck to determine whether a field that is not used anywhere in the traditional sense may actually be used inside a testing annotation.

E.g.

invalid input: '{@code
 // This field is used in the @FieldSource annotation below.
 private static final List<Integer> field = List.of(1, 2, 3);

 @ParameterizedTest
 @FieldSource("field")
 void test(int input) {
   // ...
 }
 </pre>'