private static boolean isInSynchronizedContext(PsiElement element) {
      final PsiSynchronizedStatement syncBlock = PsiTreeUtil.getParentOfType(element, PsiSynchronizedStatement.class);
      if (syncBlock != null) {
        return true;
      }
      final PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
      return method != null && method.hasModifierProperty(PsiModifier.SYNCHRONIZED) && method.hasModifierProperty(PsiModifier.STATIC);
    }
private static boolean isInSynchronizedContext(PsiElement element)