void () { ApplicationManager.getApplication().invokeLater(() -> { if (!UIUtil.hasFocus(myEditor.getContentComponent())) { return; } if (DumbService.isDumb(myProject) || !myFile.isValid()) { return; } if (myEditor.isDisposed() || myEditor instanceof EditorWindow window && !window.isValid()) { return; } int caretOffset = myEditor.getCaretModel().getOffset(); importUnambiguousImports(); if (isImportHintEnabled()) { List<HighlightInfo> visibleHighlights = getVisibleHighlights(myVisibleRange, myProject, myEditor, hasDirtyTextRange); // sort by distance to the caret visibleHighlights.sort(Comparator.comparingInt(info -> Math.abs(info.getActualStartOffset() - caretOffset))); try (AccessToken ignore = SlowOperations.knownIssue("IDEA-301732, IDEA-305605, EA-829346, EA-789713, ...")) { for (HighlightInfo visibleHighlight : visibleHighlights) { if (showAddImportHint(visibleHighlight)) { break; } } } } }, myProject.getDisposed()); }