private static void validateReferencedField(@NotNull ProblemSink problemNewBuilder, @NotNull PsiAnnotation psiAnnotation,
                                              @NotNull PsiMethod psiMethod, @NotNull PsiClass containingClass) {
    @NlsSafe final String lockFieldName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "value", "");
    if (StringUtil.isNotEmpty(lockFieldName)) {
      final boolean isStatic = psiMethod.hasModifierProperty(PsiModifier.STATIC);

      final PsiField lockField = containingClass.findFieldByName(lockFieldName, true);
      if (null != lockField) {
        if (isStatic && !lockField.hasModifierProperty(PsiModifier.STATIC)) {
          problemNewBuilder.addErrorMessage("inspection.message.synchronized.field.is.not.static", lockFieldName)
            .withLocalQuickFixes(() -> PsiQuickFixFactory.createModifierListFix(lockField, PsiModifier.STATIC, true, false));
        }
      }
      else {
        final PsiClassType javaLangObjectType =
          PsiType.getJavaLangObject(containingClass.getManager(), containingClass.getResolveScope());

        final String[] modifiers;
        if (isStatic) {
          modifiers = new String[]{PsiModifier.PRIVATE, PsiModifier.FINAL, PsiModifier.STATIC};
        }
        else {
          modifiers = new String[]{PsiModifier.PRIVATE, PsiModifier.FINAL};
        }
        problemNewBuilder.addErrorMessage("inspection.message.field.s.does.not.exist", lockFieldName)
          .withLocalQuickFixes(() -> PsiQuickFixFactory.createNewFieldFix(containingClass, lockFieldName, javaLangObjectType,
                                                                          "new Object()", modifiers));
      }
    }
  }
private static void validateReferencedField(@NotNull ProblemSink problemNewBuilder, @NotNull PsiAnnotation psiAnnotation,
                                              @NotNull PsiMethod psiMethod, @NotNull PsiClass containingClass)