@Override
      public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
        super.visitReferenceExpression(expression);
        if (expression instanceof PsiMethodReferenceExpression) return;
        if (expression.getParent() instanceof PsiMethodCallExpression && expression.getQualifierExpression() != null) return;
        PsiElement target = expression.resolve();
        // variable/parameter/field/method/class are always PsiModifierListOwners
        if (target instanceof PsiModifierListOwner &&
            !((PsiModifierListOwner)target).hasModifierProperty(PsiModifier.STATIC) &&
            !PsiTreeUtil.isAncestor(lambda, target, true)) {
          if (target instanceof PsiClass && ((PsiClass)target).getContainingClass() == null) return;
          capturing = true;
          stopWalking();
        }
      }
@Override
      public void visitReferenceExpression(@NotNull PsiReferenceExpression expression)