@@ -35,40 +35,34 @@ protected String getDiagnosticSource() {
3535 }
3636
3737 public void collectDiagnostics (PsiJavaFile unit , List <Diagnostic > diagnostics ) {
38-
3938 if (unit != null ) {
4039 PsiClass [] alltypes ;
4140 PsiField [] allFields ;
42- PsiAnnotation [] annotations ;
4341 PsiMethod [] allMethods ;
4442
4543 alltypes = unit .getClasses ();
4644 for (PsiClass type : alltypes ) {
4745 allFields = type .getFields ();
4846 for (PsiField field : allFields ) {
49- annotations = field .getAnnotations ();
50- for (PsiAnnotation annotation : annotations ) {
51- String matchedAnnotation = getMatchedJavaElementName (type , annotation .getQualifiedName (),
52- SET_OF_ANNOTATIONS .toArray (new String [0 ]));
53- if (matchedAnnotation != null ) {
54- validAnnotation (field , annotation , matchedAnnotation , diagnostics );
55- }
56- }
47+ processAnnotations (field , type , diagnostics );
5748 }
5849 allMethods = type .getMethods ();
5950 for (PsiMethod method : allMethods ) {
60- annotations = method .getAnnotations ();
61- for (PsiAnnotation annotation : annotations ) {
62- String matchedAnnotation = getMatchedJavaElementName (type , annotation .getQualifiedName (),
63- SET_OF_ANNOTATIONS .toArray (new String [0 ]));
64- if (matchedAnnotation != null ) {
65- validAnnotation (method , annotation , matchedAnnotation , diagnostics );
66- }
67- }
51+ processAnnotations (method , type , diagnostics );
6852 }
6953 }
7054 }
55+ }
7156
57+ private void processAnnotations (PsiJvmModifiersOwner psiModifierOwner , PsiClass type , List <Diagnostic > diagnostics ) {
58+ PsiAnnotation [] annotations = psiModifierOwner .getAnnotations ();
59+ for (PsiAnnotation annotation : annotations ) {
60+ String matchedAnnotation = getMatchedJavaElementName (type , annotation .getQualifiedName (),
61+ SET_OF_ANNOTATIONS .toArray (new String [0 ]));
62+ if (matchedAnnotation != null ) {
63+ validAnnotation (psiModifierOwner , annotation , matchedAnnotation , diagnostics );
64+ }
65+ }
7266 }
7367
7468 private void validAnnotation (PsiElement element , PsiAnnotation annotation , String matchedAnnotation ,
0 commit comments