void () { WriteAction.run(() -> { PsiFile file = createXmlScratch(); Document document = FileDocumentManager.getInstance().getDocument(file.getVirtualFile()); document.setText("<"); Editor editor = ((TextEditor)FileEditorManager.getInstance(getProject()).openFile(file.getVirtualFile(), true)[0]).getEditor(); editor.getCaretModel().moveToOffset(1); new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), editor); }); }