@Override
  public @NotNull Result charTyped(char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    if (c == '?' && file.getLanguage() == XMLLanguage.INSTANCE) {
      int offset = editor.getCaretModel().getOffset();
      if (offset >= 2 && editor.getDocument().getCharsSequence().charAt(offset - 2) == '<') {
        PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
        PsiElement at = file.findElementAt(offset - 2);
        if (at != null && at.getNode().getElementType() == XmlTokenType.XML_PI_START &&
            editor.getDocument().getText().indexOf("?>", offset) == -1) {

          editor.getDocument().insertString(offset, " ?>");
          AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
        }
      }
    }
    return super.charTyped(c, project, editor, file);
  }
@Override
  public @NotNull Result charTyped(char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file)