void (char completionChar, @Nullable final LookupElement item) { LOG.assertTrue(!ApplicationManager.getApplication().isWriteAccessAllowed(), "finishLookup should be called without a write action"); final PsiFile file = getPsiFile(); boolean writableOk = file == null || FileModificationService.getInstance().prepareFileForWrite(file); if (isLookupDisposed()) { // ensureFilesWritable could close us by showing a dialog return; } if (!writableOk) { hideWithItemSelected(null, completionChar); return; } CommandProcessor.getInstance().executeCommand(myProject, () -> finishLookupInWritableFile(completionChar, item), null, null); }