@Override
  protected void collectInformationWithProgress(@NotNull ProgressIndicator progress) {
    ApplicationManager.getApplication().assertIsNonDispatchThread();

    DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
    myHighlightVisitorRunner.createHighlightVisitorsFor(filteredVisitors->{
      List<Divider.DividedElements> dividedElements = new ArrayList<>();
      List<Divider.DividedElements> notVisitableElements = new ArrayList<>();
      Divider.divideInsideAndOutsideAllRoots(getFile(), myRestrictRange, myPriorityRange, psiFile -> true,
                                             elements -> {
                                               if (SHOULD_HIGHLIGHT_FILTER.test(elements.psiRoot())) {
                                                 dividedElements.add(elements);
                                               }
                                               else {
                                                 notVisitableElements.add(elements);
                                               }
                                               return false;
                                             });
      List<PsiElement> allInsideElements = ContainerUtil.concat(ContainerUtil.map(dividedElements,
                                            dividedForRoot -> {
                                              List<? extends PsiElement> inside = dividedForRoot.inside();
                                              PsiElement lastInside = ContainerUtil.getLastItem(inside);
                                              return lastInside instanceof PsiFile && !(lastInside instanceof PsiCodeFragment) ? inside
                                                .subList(0, inside.size() - 1) : inside;
                                            }));


      List<LongList> map = ContainerUtil.map(dividedElements,
                                             dividedForRoot -> {
                                               LongList insideRanges = dividedForRoot.insideRanges();
                                               PsiElement lastInside = ContainerUtil.getLastItem(dividedForRoot.inside());
                                               return lastInside instanceof PsiFile && !(lastInside instanceof PsiCodeFragment)
                                                      ? insideRanges.subList(0, insideRanges.size() - 1) : insideRanges;
                                             });

      LongList allInsideRanges = ContainerUtil.reduce(map, new LongArrayList(map.isEmpty() ? 1 : map.get(0).size()), (l1, l2)->{ l1.addAll(l2); return l1;});

      List<PsiElement> allOutsideElements = ContainerUtil.concat(ContainerUtil.map(dividedElements,
                                                  dividedForRoot -> {
                                                    List<? extends PsiElement> outside = dividedForRoot.outside();
                                                    PsiElement lastInside = ContainerUtil.getLastItem(dividedForRoot.inside());
                                                    return lastInside instanceof PsiFile && !(lastInside instanceof PsiCodeFragment) ? ContainerUtil.append(outside,
                                                      lastInside) : outside;
                                                  }));
      List<LongList> map1 = ContainerUtil.map(dividedElements,
                                              dividedForRoot -> {
                                                LongList outsideRanges = dividedForRoot.outsideRanges();
                                                PsiElement lastInside = ContainerUtil.getLastItem(dividedForRoot.inside());
                                                long lastInsideRange = dividedForRoot.insideRanges().isEmpty() ? -1 : dividedForRoot.insideRanges().getLong(dividedForRoot.insideRanges().size()-1);
                                                if (lastInside instanceof PsiFile && !(lastInside instanceof PsiCodeFragment) && lastInsideRange != -1) {
                                                  LongArrayList r = new LongArrayList(outsideRanges);
                                                  r.add(lastInsideRange);
                                                  return r;
                                                }
                                                return outsideRanges;
                                              });
      LongList allOutsideRanges = ContainerUtil.reduce(map1, new LongArrayList(map1.isEmpty() ? 1 : map1.get(0).size()), (l1, l2)->{ l1.addAll(l2); return l1;});


      setProgressLimit(allInsideElements.size() + allOutsideElements.size());

      boolean forceHighlightParents = forceHighlightParents();

      // clear highlights generated by visitors called on psi elements no longer highlightable under the current highlighting level (e.g., when the file level was changed from "All Problems" to "None")
      for (Divider.DividedElements notVisitable : notVisitableElements) {
        for (PsiElement element : ContainerUtil.concat(notVisitable.inside(), notVisitable.outside())) {
          for (HighlightVisitor visitor : filteredVisitors) {
            myHighlightInfoUpdater.psiElementVisited(visitor.getClass(), element, List.of(), getDocument(), getFile(), myProject, getHighlightingSession());
          }
        }
      }

      boolean success = collectHighlights(allInsideElements, allInsideRanges, allOutsideElements, allOutsideRanges, filteredVisitors,
                                          forceHighlightParents, (toolId, psiElement, newInfos) -> {
          myHighlightInfoUpdater.psiElementVisited(toolId, psiElement, newInfos, getDocument(), getFile(), myProject, getHighlightingSession());
          myHighlights.addAll(newInfos);
          if (psiElement instanceof PsiErrorElement) {
            myHasErrorElement = true;
          }
          for (HighlightInfo info : newInfos) {
            if (info.getSeverity() == HighlightSeverity.ERROR) {
              myHasErrorSeverity = true;
              break;
            }
          }
        });
      if (success) {
        if (myUpdateAll) {
          daemonCodeAnalyzer.getFileStatusMap().setErrorFoundFlag(myProject, getDocument(), myHasErrorSeverity);
          reportErrorsToWolf(myHasErrorSeverity);
        }
      }
      else {
        cancelAndRestartDaemonLater(progress, myProject);
      }
    });
  }
@Override
  protected void collectInformationWithProgress(@NotNull ProgressIndicator progress)