void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { PsiFile file = tag.getContainingFile(); Language language = file.getLanguage(); // Support JSP & JSPX but exclude JavaScript Frameworks if (!(!(language instanceof HTMLLanguage) || language == HTMLLanguage.INSTANCE)) return; if (!HtmlUtil.isHtmlTagContainingFile(tag)) { return; } final String tagName = StringUtil.toLowerCase(tag.getName()); if (ourInputElements.contains(tagName)) { if (tag.getAttribute("aria-label") != null || tag.getAttribute("title") != null) return; if ("input".equals(tagName)) { XmlAttribute type = tag.getAttribute("type"); if (type != null) { String attrValue = type.getValue(); if (attrValue != null) { if (tag instanceof HtmlTag) attrValue = StringUtil.toLowerCase(attrValue); if (ourNonlabelInputTypes.contains(attrValue)) return; } } } if (file instanceof XmlFile) { HtmlLabelsHolder labelsHolder = HtmlLabelsHolder.getInstance((XmlFile)file); boolean hasLabel = false; for (XmlAttribute attribute : tag.getAttributes()) { if (StringUtil.toLowerCase(attribute.getName()).equals("id") || isImplicitIdAttribute(attribute)) { String id = attribute.getValue(); if (id != null && labelsHolder.hasForValue(id)) { hasLabel = true; break; } } } PsiElement child = tag; while (!hasLabel) { PsiElement parent = child.getParent(); if (parent == null) break; if (parent instanceof XmlTag && "label".equals(StringUtil.toLowerCase(((XmlTag)parent).getName()))) { boolean anotherLabel = false; for (PsiElement element : parent.getChildren()) { if (element == child) { break; } else if (element instanceof XmlTag && "label".equals(StringUtil.toLowerCase(((XmlTag)element).getName()))) { anotherLabel = true; } } hasLabel = !anotherLabel; } child = parent; } if (!hasLabel) { registerProblem(tag, holder); } } } }