private void findUnusedLocalVariablesInElement(@NotNull PsiElement element, @NotNull List<? super CommonProblemDescriptor> descriptors) {
      Set<PsiVariable> usedVariables = new HashSet<>();
      List<DefUseUtil.Info> unusedDefs = DefUseUtil.getUnusedDefs(element, usedVariables);
      if (unusedDefs != null && !unusedDefs.isEmpty()) {
        for (DefUseUtil.Info varDefInfo : unusedDefs) {
          PsiElement parent = varDefInfo.getContext();
          PsiVariable variable = varDefInfo.getVariable();
          if (variable.isUnnamed() || PsiUtil.isIgnoredName(variable.getName())) continue;
          if (parent instanceof PsiDeclarationStatement || parent instanceof PsiForeachStatement ||
              variable instanceof PsiResourceVariable || variable instanceof PsiPatternVariable) {
            if (!varDefInfo.isRead() && !SuppressionUtil.inspectionResultSuppressed(variable, UnusedDeclarationInspection.this)) {
              descriptors.add(createProblemDescriptor(variable));
            }
          }
        }
      }
      element.accept(new JavaRecursiveElementWalkingVisitor() {
        @Override
        public void visitClass(@NotNull PsiClass aClass) {
          // prevent going to local classes
        }

        @Override
        public void visitLambdaExpression(@NotNull PsiLambdaExpression lambdaExpr) {
          PsiElement body = lambdaExpr.getBody();
          if (body == null) return;
          findUnusedLocalVariablesInElement(body, descriptors);
        }

        @Override
        public void visitLocalVariable(@NotNull PsiLocalVariable variable) {
          super.visitLocalVariable(variable);
          if (!usedVariables.contains(variable) && variable.getInitializer() == null &&
              !SuppressionUtil.inspectionResultSuppressed(variable, UnusedDeclarationInspection.this)) {
            descriptors.add(createProblemDescriptor(variable));
          }
        }
      });
    }
private void findUnusedLocalVariablesInElement(@NotNull PsiElement element, @NotNull List<? super CommonProblemDescriptor> descriptors)