@Override
  protected boolean isResourceFactoryClosed(PsiExpression expression) {
    if (!(expression instanceof PsiMethodCallExpression methodCallExpression)) {
      return false;
    }
    final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
    final PsiExpression qualifier = methodExpression.getQualifierExpression();
    if (!(qualifier instanceof PsiReferenceExpression referenceExpression)) {
      return false;
    }
    final PsiElement target = referenceExpression.resolve();
    if (!(target instanceof PsiVariable variable)) {
      return false;
    }
    PsiTryStatement tryStatement = PsiTreeUtil.getParentOfType(expression, PsiTryStatement.class, true, PsiMember.class);
    if (tryStatement == null) {
      return false;
    }
    while (!isResourceClosedInFinally(tryStatement, variable)) {
      tryStatement = PsiTreeUtil.getParentOfType(tryStatement, PsiTryStatement.class, true, PsiMember.class);
      if (tryStatement == null) {
        return false;
      }
    }
    return true;
  }
@Override
  protected boolean isResourceFactoryClosed(PsiExpression expression)