void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HtmlUtil.isHtmlTagContainingFile(tag)) return; final XmlAttribute lang = tag.getAttribute(LANG); final XmlAttribute xmlLang = tag.getAttribute(XML_LANG); final String tagName = tag.getName(); List<LocalQuickFix> fixes = new ArrayList<>(); if (!tagName.equalsIgnoreCase(HTML)) return; //HTML only offers the use of the lang attribute, while XHTML 1.0 allows both attributes, and XHTML 1.1 allows only xml:lang. if (tag.getContainingFile().getFileType() == XHtmlFileType.INSTANCE) { XmlDocument doc = PsiTreeUtil.getContextOfType(tag, XmlDocument.class, true); //Do not inspect the xhtml file without doctype if (doc == null || doc.getProlog() == null || doc.getProlog().getDoctype() == null || doc.getProlog().getDoctype().getPublicId() == null) return; if (doc.getProlog().getDoctype().getPublicId().contains(XHTML_1)) { if (xmlLang != null || lang != null) return; if (isOnTheFly) fixes.add(new InsertRequiredAttributeFix(tag, XML_LANG)); } else if (doc.getProlog().getDoctype().getPublicId().contains(XHTML_11)) { if (tag.getAttribute(XML_LANG) != null) return; if (isOnTheFly) fixes.add(new InsertRequiredAttributeFix(tag, XML_LANG)); } } else if (tag.getContainingFile().getFileType() == HtmlFileType.INSTANCE) { if (tag.getAttribute(LANG) != null) return; if (isOnTheFly) fixes.add(new InsertRequiredAttributeFix(tag, LANG)); } else { return; } InspectionUtils.RegisterProblem(tag, holder, fixes, HtmlToolsBundle.message("html.inspections.check.required.lang"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }