@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new JavaElementVisitor() {
      @Override
      public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
        visitExpression(expression);
      }

      @Override
      public void visitExpression(@NotNull PsiExpression expression) {
        if (expression instanceof PsiLiteralExpression) return;
        DataflowResult dfr = CommonDataflow.getDataflowResult(expression);
        if (dfr == null) return;
        JavaDfaAnchor anchor = expression instanceof PsiMethodReferenceExpression methodRef ?
                               new JavaMethodReferenceReturnAnchor(methodRef) :
                               new JavaExpressionAnchor(expression);
        processAnchor(dfr, anchor, holder);
        if (expression instanceof PsiPolyadicExpression polyadic) {
          PsiExpression[] operands = polyadic.getOperands();
          for (int i = 1; i < operands.length - 1; i++) {
            processAnchor(dfr, new JavaPolyadicPartAnchor(polyadic, i), holder);
          }
        }
      }

      @Override
      public void visitSwitchLabeledRuleStatement(@NotNull PsiSwitchLabeledRuleStatement statement) {
        checkSwitchCaseGuard(PsiUtil.skipParenthesizedExprDown(statement.getGuardExpression()));
      }

      @Override
      public void visitSwitchLabelStatement(@NotNull PsiSwitchLabelStatement statement) {
        checkSwitchCaseGuard(PsiUtil.skipParenthesizedExprDown(statement.getGuardExpression()));
      }

      private void checkSwitchCaseGuard(@Nullable PsiExpression guard) {
        if (guard == null) return;
        if (BoolUtils.isTrue(guard)) {
          LocalQuickFix fix = createSimplifyBooleanExpressionFix(guard, guard.textMatches(PsiKeyword.TRUE));
          holder.registerProblem(guard, JavaAnalysisBundle
            .message("dataflow.message.constant.no.ref", guard.textMatches(PsiKeyword.TRUE) ? 1 : 0), LocalQuickFix.notNullElements(fix));
        }
      }

      @Override
      public void visitIfStatement(@NotNull PsiIfStatement statement) {
        PsiExpression condition = PsiUtil.skipParenthesizedExprDown(statement.getCondition());
        if (BoolUtils.isBooleanLiteral(condition)) {
          LocalQuickFix fix = createSimplifyBooleanExpressionFix(condition, condition.textMatches(PsiKeyword.TRUE));
          holder.registerProblem(condition, JavaAnalysisBundle
            .message("dataflow.message.constant.no.ref", condition.textMatches(PsiKeyword.TRUE) ? 1 : 0), LocalQuickFix.notNullElements(fix));
        }
      }

      @Override
      public void visitDoWhileStatement(@NotNull PsiDoWhileStatement statement) {
        PsiExpression condition = PsiUtil.skipParenthesizedExprDown(statement.getCondition());
        if (condition != null && condition.textMatches(PsiKeyword.FALSE)) {
          LocalQuickFix fix = createSimplifyBooleanExpressionFix(condition, false);
          if (fix != null) {
            holder.registerProblem(condition, JavaAnalysisBundle.message("dataflow.message.constant.no.ref", 0),
                                   LocalQuickFix.notNullElements(fix));
          }
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)