AnnotationPlace (@NotNull PsiElement element) { PsiFile containingFile = element.getContainingFile(); Project project = containingFile.getProject(); final MyExternalPromptDialog dialog = ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment() ? null : new MyExternalPromptDialog(project); if (dialog != null && dialog.isToBeShown()) { final PsiElement highlightElement = element instanceof PsiNameIdentifierOwner ? ((PsiNameIdentifierOwner)element).getNameIdentifier() : element.getNavigationElement(); LOG.assertTrue(highlightElement != null); final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); final List<RangeHighlighter> highlighters = new ArrayList<>(); final boolean highlight = editor != null && editor.getDocument() == PsiDocumentManager.getInstance(project).getDocument(containingFile); try { if (highlight) { //do not highlight for batch inspections final TextRange textRange = highlightElement.getTextRange(); HighlightManager.getInstance(project).addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(textRange.getStartOffset()); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.CENTER); } dialog.show(); if (dialog.getExitCode() == 2) { return AnnotationPlace.EXTERNAL; } else if (dialog.getExitCode() == 1) { return AnnotationPlace.NOWHERE; } } finally { if (highlight) { HighlightManager.getInstance(project).removeSegmentHighlighter(editor, highlighters.get(0)); } } } else if (dialog != null) { dialog.close(DialogWrapper.OK_EXIT_CODE); } return AnnotationPlace.IN_CODE; }