CodeInsightActionHandler () { return new CodeInsightActionHandler() { @Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument()); ReadAction.nonBlocking(() -> EmmetPreviewUtil.calculateTemplateText(editor, file, true)) .finishOnUiThread(ModalityState.any(), templateText -> { if (StringUtil.isEmpty(templateText)) { CommonRefactoringUtil.showErrorHint(project, editor, XmlBundle.message("cannot.show.preview.for.given.abbreviation"), XmlBundle.message("emmet.preview"), null); return; } EmmetPreviewHint.createHint((EditorEx)editor, templateText, file.getFileType()).showHint(); EmmetPreviewUtil.addEmmetPreviewListeners(editor, file, true); }) .expireWith(() -> editor.isDisposed()) .submit(AppExecutorUtil.getAppExecutorService()); } @Override public boolean startInWriteAction() { return false; } }; }