private static void addXmlProcessingInstructions(@NotNull List<LookupElement> elements, @NotNull XmlTag tag) {
    final PsiElement file = tag.getParent();
    final PsiElement prolog = file.getFirstChild();
    if (prolog.getTextLength() != 0) {
      // "If [the XML Prolog] exists, it must come first in the document."
      return;
    }

    if (ContainerUtil.exists(tag.getChildren(), OuterLanguageElement.class::isInstance)) {
      return;
    }

    final LookupElementBuilder xmlDeclaration = LookupElementBuilder
      .create("?xml version=\"1.0\" encoding=\"\" ?>")
      .withPresentableText("<?xml version=\"1.0\" encoding=\"\" ?>")
      .withInsertHandler((context, item) -> {
        int offset = context.getEditor().getCaretModel().getOffset();
        context.getEditor().getCaretModel().moveToOffset(offset - 4);
        AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor());
      });
    elements.add(xmlDeclaration);
  }
private static void addXmlProcessingInstructions(@NotNull List<LookupElement> elements, @NotNull XmlTag tag)