CollectingInfoRunnable (final @NotNull PsiFile file) { return new CollectingInfoRunnable() { int myRemovedNameSpaces = 0; @Override public void run() { XmlFile xmlFile = (XmlFile)file; Project project = xmlFile.getProject(); HighlightDisplayKey key = HighlightDisplayKey.find(myInspection.getShortName()); if (!InspectionProjectProfileManager.getInstance(project).getCurrentProfile().isToolEnabled(key, xmlFile)) return; ProblemsHolder holder = new ProblemsHolder(InspectionManager.getInstance(project), xmlFile, false); final XmlElementVisitor visitor = (XmlElementVisitor)myInspection.buildVisitor(holder, false); new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof XmlAttribute) { visitor.visitXmlAttribute((XmlAttribute)element); } else { super.visitElement(element); } } }.visitFile(xmlFile); ProblemDescriptor[] results = holder.getResultsArray(); List<ProblemDescriptor> list = ContainerUtil.filter(results, myCondition); Map<XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix, ProblemDescriptor> fixes = new LinkedHashMap<>(); for (ProblemDescriptor result : list) { for (QuickFix fix : result.getFixes()) { if (fix instanceof XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix) { fixes.put((XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix)fix, result); } } } SmartPsiElementPointer<XmlTag> pointer = null; for (Map.Entry<XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix, ProblemDescriptor> fix : fixes.entrySet()) { pointer = fix.getKey().doFix(project, fix.getValue(), false); myRemovedNameSpaces++; } if (pointer != null) { XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.reformatStartTag(project, pointer); } } @Override public @Nullable String getUserNotificationInfo() { return myRemovedNameSpaces > 0 ? XmlBundle.message("hint.text.removed.namespace", myRemovedNameSpaces, myRemovedNameSpaces > 1 ? 0 : 1) : null; } }; }