Result (@NotNull Editor editor, boolean allowPopup, boolean allowCaretNearRef, boolean mayAddUnambiguousImportsSilently) { ThreadingAssertions.assertEventDispatchThread(); List<? extends PsiClass> result = getClassesToImport(); PsiClass[] classes = result.toArray(PsiClass.EMPTY_ARRAY); if (classes.length == 0) return Result.POPUP_NOT_SHOWN; PsiFile psiFile = myContainingFile; if (psiFile == null || !psiFile.isValid()) return Result.POPUP_NOT_SHOWN; Project project = psiFile.getProject(); if (!isStillAvailable()) return Result.POPUP_NOT_SHOWN; QuestionAction action = createAddImportAction(classes, project, editor); boolean canImportHere = true; if (classes.length == 1 && (canImportHere = canImportHere(allowCaretNearRef, editor)) && mayAddUnambiguousImportsSilently && !autoImportWillInsertUnexpectedCharacters(classes[0])) { CommandProcessor.getInstance().runUndoTransparentAction(() -> action.execute()); return Result.CLASS_AUTO_IMPORTED; } if (allowPopup && canImportHere) { if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) { String hintText = ShowAutoImportPass.getMessage(classes.length > 1, IdeBundle.message("go.to.class.kind.text"), classes[0].getQualifiedName()); HintManager.getInstance().showQuestionHint(editor, hintText, getStartOffset(myReferenceElement, myReference), getEndOffset(myReferenceElement, myReference), action); } return Result.POPUP_SHOWN; } return Result.POPUP_NOT_SHOWN; }