IntentionAction[] (PsiReference reference, String localName) { PsiElement element = reference.getElement(); XmlElementFactory factory = XmlElementFactory.getInstance(element.getProject()); XmlTag tag = factory.createTagFromText("<" + reference.getCanonicalText() + ":" + localName + " />", XMLLanguage.INSTANCE); XmlFile xmlFile = PsiTreeUtil.getContextOfType(element, XmlFile.class, true); return xmlFile == null ? IntentionAction.EMPTY_ARRAY : new IntentionAction[]{ new MyCreateNSDeclarationAction(tag, reference.getCanonicalText(), xmlFile) }; }