HTML: don't report missing close tag on empty collapsed tag (WEB-33628)

This commit is contained in:
Konstantin Ulitin
2018-07-05 13:30:42 +03:00
parent c9d09f0c8a
commit 32c0677657
2 changed files with 7 additions and 1 deletions

View File

@@ -48,7 +48,9 @@ public class HtmlMissingClosingTagInspectionTest extends LightPlatformCodeInsigh
quickfixTest("<html><<warning descr=\"Element <p> is missing an end tag\">p</warning><caret>>Behold!</html>", "<html><p>Behold!</p></html>", "Add </p>");
}
public void testCollapsedEmptyTag() {
highlightTest("<html><body><App/></body></html>");
}
@NotNull
protected LocalInspectionTool getInspection() {

View File

@@ -17,6 +17,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlText;
import com.intellij.psi.xml.XmlToken;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.xml.util.HtmlUtil;
import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.Nls;
@@ -36,6 +37,9 @@ public class HtmlMissingClosingTagInspection extends HtmlLocalInspectionTool {
if (child instanceof PsiErrorElement) {
return;
}
if (child != null && child.getNode().getElementType() == XmlTokenType.XML_EMPTY_ELEMENT_END) {
return;
}
final XmlToken tagNameElement = XmlTagUtil.getStartTagNameElement(tag);
if (tagNameElement == null) {
return;