void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement psiElement = descriptor.getPsiElement(); final PsiFile psiFile = psiElement.getContainingFile(); WriteCommandAction.writeCommandAction(project, psiFile).run(() -> { final XmlTag tag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class); if (tag == null) return; final Language language = psiFile.getViewProvider().getBaseLanguage(); final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(language); if (commenter == null) return; String commentText = commenter.getBlockCommentPrefix() + "@declare id=\"" + myId + "\"" + commenter.getBlockCommentSuffix(); XmlTag parent = tag.getParentTag(); if (parent != null) { Document document = Objects.requireNonNull(psiFile.getViewProvider().getDocument()); document.insertString(parent.getSubTags()[0].getTextRange().getStartOffset(), commentText); } }); }