void (@NotNull PsiModifierList beforeModifierList, @NotNull PsiModifierList afterModifierList) { for (String modifier : PsiModifier.MODIFIERS) { boolean haveSameModifiers = afterModifierList.hasModifierProperty(modifier) == beforeModifierList.hasModifierProperty(modifier); if (!haveSameModifiers) { final PsiMethod afterModifierListParentMethod = PsiTreeUtil.getContextOfType(afterModifierList, PsiMethod.class); final PsiMethod afterModifierListParentField = PsiTreeUtil.getContextOfType(afterModifierList, PsiMethod.class); final PsiClass afterModifierListParentClass = PsiTreeUtil.getContextOfType(afterModifierList, PsiClass.class); final String target; if (afterModifierListParentMethod != null) { target = afterModifierListParentMethod.getText(); } else if (afterModifierListParentField != null) { target = afterModifierListParentField.getName(); } else { target = afterModifierListParentClass.getName(); } fail(modifier + " Modifier is not equal for " + target); } } compareAnnotations(beforeModifierList, afterModifierList); }