void (@NotNull List<? extends PsiElement> elements, @NotNull PsiFile containingFile, @NotNull List<? extends LineMarkerProvider> providers, @NotNull PairConsumer<? super PsiElement, ? super LineMarkerInfo<?>> consumer) { ApplicationManager.getApplication().assertReadAccessAllowed(); if (myMode != Mode.SLOW) { //noinspection ForLoopReplaceableByForEach for (int i = 0; i < elements.size(); i++) { PsiElement element = elements.get(i); //noinspection ForLoopReplaceableByForEach for (int j = 0; j < providers.size(); j++) { ProgressManager.checkCanceled(); LineMarkerProvider provider = providers.get(j); LineMarkerInfo<?> info; try { info = provider.getLineMarkerInfo(element); } catch (ProcessCanceledException | IndexNotReadyException e) { throw e; } catch (Exception e) { LOG.error("During querying provider " + provider + " (" + provider.getClass() + ")", e, new Attachment(containingFile.getViewProvider().getVirtualFile().getName(), containingFile.getText())); continue; } if (info != null) { if (info.endOffset > getDocument().getTextLength()) { Exception exception = new IllegalStateException(provider + " (" + provider.getClass() + ")" + " generated invalid LineMarker " + info + " for element " + element + " (" + element.getClass() + ")." + " document length: " + getDocument().getTextLength()); LOG.error(PluginException.createByClass(exception, provider.getClass())); } consumer.consume(element, info); } } } } if (myMode == Mode.FAST) return; if (InjectionUtils.shouldCollectLineMarkersForInjectedFiles(myFile)) { Set<PsiFile> visitedInjectedFiles = new HashSet<>(); // line markers for injected could be slow //noinspection ForLoopReplaceableByForEach for (int i = 0; i < elements.size(); i++) { PsiElement element = elements.get(i); queryLineMarkersForInjected(element, containingFile, visitedInjectedFiles, consumer); } } List<LineMarkerInfo<?>> slowLineMarkers = new NotNullList<>(); //noinspection ForLoopReplaceableByForEach for (int j = 0; j < providers.size(); j++) { ProgressManager.checkCanceled(); LineMarkerProvider provider = providers.get(j); try { provider.collectSlowLineMarkers(elements, slowLineMarkers); } catch (ProcessCanceledException | IndexNotReadyException e) { throw e; } catch (Exception e) { LOG.error(e); continue; } if (!slowLineMarkers.isEmpty()) { //noinspection ForLoopReplaceableByForEach for (int k = 0; k < slowLineMarkers.size(); k++) { LineMarkerInfo<?> slowInfo = slowLineMarkers.get(k); PsiElement element = slowInfo.getElement(); consumer.consume(element, slowInfo); } slowLineMarkers.clear(); } } }