void (final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { PsiElement parent = descriptor.getPsiElement(); while (parent != null) { if (parent instanceof XmlTag && Holder.ourTagToCssMap.containsKey(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) { break; } parent = parent.getParent(); } if (parent == null) { return; } XmlTag tag = (XmlTag)parent; XmlTag parentTag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); boolean toReplaceWithSpan = parentTag == null || HtmlUtil.isInlineTagContainer(parentTag.getLocalName(), false); if (!toReplaceWithSpan) { String name = StringUtil.toLowerCase(parentTag.getLocalName()); if (BODY.equals(name) || HTML.equals(name) || HEAD.equals(name)) { toReplaceWithSpan = true; } else { int childrenTagCount = 0; for (PsiElement child : parentTag.getChildren()) { if (child instanceof XmlTag) { childrenTagCount++; } if (child instanceof XmlText) { childrenTagCount += 2; } } toReplaceWithSpan = childrenTagCount > 1; } } final String tagName = StringUtil.toLowerCase(((XmlTag)parent).getLocalName()); if (!toReplaceWithSpan) { addCssAttribute(parentTag, tagName); PsiElement[] elements = tag.getChildren(); boolean started = false; for (PsiElement psiElement : elements) { if (psiElement instanceof XmlToken xmlToken) { IElementType type = xmlToken.getTokenType(); if (type == XmlTokenType.XML_TAG_END) { started = true; continue; } else if (type == XmlTokenType.XML_END_TAG_START) { break; } } if (started) { parentTag.addBefore(psiElement, tag); } } tag.delete(); } else { PsiElement[] elements = generateContainingElements(project, HtmlUtil.isHtmlBlockTag(tagName, false)); int cnt = 0; for (PsiElement psiElement : tag.getChildren()) { if (psiElement instanceof XmlToken) { IElementType type = ((XmlToken)psiElement).getTokenType(); if (type == XmlTokenType.XML_NAME) { psiElement.replace(elements[cnt++]); } } } addCssAttribute(tag, tagName); } }