public static boolean isInSynchronizedContext(PsiElement element) {
    final PsiElement context =
      PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiSynchronizedStatement.class, PsiClass.class, PsiLambdaExpression.class);
    if (context instanceof PsiSynchronizedStatement) {
      return true;
    }
    if (context instanceof PsiMethod modifierListOwner) {
      if (modifierListOwner.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
        return true;
      }
    }
    if (context instanceof PsiMethod || context instanceof PsiLambdaExpression) {
      PsiAssertStatement assertStatement = findHoldsLockAssertion(context);
      return assertStatement != null && assertStatement.getTextOffset() + assertStatement.getTextLength() < element.getTextOffset();
    }
    return false;
  }
public static boolean isInSynchronizedContext(PsiElement element)