LookupElement[] (@NotNull final CompletionType type, final int invocationCount) { myEmptyLookup = false; ApplicationManager.getApplication().invokeAndWait(() -> CommandProcessor.getInstance().executeCommand(myProject, () -> { final CodeCompletionHandlerBase handler = new CodeCompletionHandlerBase(type) { @Override protected void completionFinished(CompletionProgressIndicator indicator, boolean hasModifiers) { myEmptyLookup = indicator.getLookup().getItems().isEmpty(); super.completionFinished(indicator, hasModifiers); } }; Editor editor = getCompletionEditor(); assertNotNull(editor); handler.invokeCompletion(myProject, editor, invocationCount); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); // to compare with file text }, null, null, myEditor.getDocument())); return getLookupElements(); }