void (@NotNull final PsiErrorElement element, @NotNull final HighlightInfo.Builder highlightInfo) { if (PsiTreeUtil.getParentOfType(element, XmlTag.class) == null) { return; } final String text = element.getErrorDescription(); if (text.equals(XmlPsiBundle.message("xml.parsing.unescaped.ampersand.or.nonterminated.character.entity.reference"))) { final int textOffset = element.getTextOffset(); highlightInfo.registerFix(new IntentionAction() { @Override @NotNull public String getText() { return XmlAnalysisBundle.message("xml.quickfix.escape.ampersand"); } @Override @NotNull public String getFamilyName() { return getText(); } @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return true; } @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) { PsiFile topLevelFile = InjectedLanguageManager.getInstance(project).getTopLevelFile(file); Document document = topLevelFile.getViewProvider().getDocument(); assert document != null; document.replaceString(textOffset, textOffset + 1, AMP_ENTITY); } @Override public boolean startInWriteAction() { return true; } }, null, null, null, null); } }