private static void contextCompleted(@NotNull InspectionContext context,
                                       @NotNull LocalInspectionToolSession session,
                                       @NotNull JobLauncherImpl.QueueController<? super InspectionContext> addToQueue,
                                       int initSize,
                                       @NotNull AtomicInteger addedInvisibles,
                                       @NotNull Consumer<? super InspectionContext> contextFinishedCallback) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("onComplete: " + context + "; visible=" + context.isVisible()+"; holder:"+context.holder.getResults());
    }
    if (context.isVisible()) {
      // after the visible part is finished, queue the invisible part
      InspectionContext invisibleContext =
        new InspectionContext(context.tool(), context.holder(), context.visitor(), context.elementsInside(), context.elementsOutside(),
                              false, context.acceptingPsiTypes(), context.psiFile());
      addToQueue.enqueue(invisibleContext);
      if (addedInvisibles.incrementAndGet() == initSize) {
        addToQueue.finish();
      }
    }
    else {
      // both 'inside' and 'outside' elements are visited, the inspection is considered finished
      InspectionProblemHolder holder = context.holder;
      holder.toolStamps.finishTimeStamp = System.nanoTime();
      context.tool.getTool().inspectionFinished(session, holder);
      // report descriptors which were added by crazy inspections in their inspectionFinished() as the result of "visiting" fake element
      holder.reportAddedDescriptors(HighlightInfoUpdaterImpl.FAKE_ELEMENT);
      contextFinishedCallback.accept(context);
    }
  }
private static void contextCompleted(@NotNull InspectionContext context,
                                       @NotNull LocalInspectionToolSession session,
                                       @NotNull JobLauncherImpl.QueueController<? super InspectionContext> addToQueue,
                                       int initSize,
                                       @NotNull AtomicInteger addedInvisibles,
                                       @NotNull Consumer<? super InspectionContext> contextFinishedCallback)