@Override
                public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) {
                  final Editor editor = context.getEditor();
                  final Document document = context.getDocument();
                  final int caretOffset = editor.getCaretModel().getOffset();
                  final RangeMarker caretMarker = document.createRangeMarker(caretOffset, caretOffset);
                  caretMarker.setGreedyToRight(true);

                  XmlFile psiFile = (XmlFile)context.getFile();
                  boolean incomplete = XmlUtil.getTokenOfType(tag, XmlTokenType.XML_TAG_END) == null &&
                                       XmlUtil.getTokenOfType(tag, XmlTokenType.XML_EMPTY_ELEMENT_END) == null;
                  XmlNamespaceHelper.getHelper(psiFile).insertNamespaceDeclaration(psiFile, editor, Collections.singleton(ns), null, null);
                  editor.getCaretModel().moveToOffset(caretMarker.getEndOffset());

                  XmlTag rootTag = psiFile.getRootTag();
                  if (incomplete) {
                    XmlToken token = XmlUtil.getTokenOfType(rootTag, XmlTokenType.XML_EMPTY_ELEMENT_END);
                    if (token != null) token.delete(); // remove tag end added by smart attribute adder :(
                    PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(document);
                    super.handleInsert(context, item);
                  }
                }
@Override
                public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item)