void (PsiReference[] references) { if (references.length == 0) { return; } XmlAttributeValue element = (XmlAttributeValue)references[0].getElement(); XmlAttribute attribute = (XmlAttribute)element.getParent(); if (element.getReferences().length == references.length) { // all refs to be removed attribute.delete(); return; } PsiFile file = element.getContainingFile(); Project project = file.getProject(); SmartPsiElementPointer<XmlAttribute> pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(attribute); for (PsiReference reference : references) { RemoveNamespaceDeclarationFix.removeReferenceText(reference); } // trimming the result PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); Document document = file.getViewProvider().getDocument(); assert document != null; documentManager.commitDocument(document); String trimmed = element.getValue().trim(); XmlAttribute pointerElement = pointer.getElement(); assert pointerElement != null; pointerElement.setValue(trimmed); }