Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
6,800
|
boolean (@NotNull String forValue) { return myForValuesOfLabels.contains(forValue); }
|
hasForValue
|
6,801
|
void (@NotNull XmlTag tag) { super.visitXmlTag(tag); if ("label".equals(StringUtil.toLowerCase(tag.getName()))) { for (XmlAttribute attribute : tag.getAttributes()) { if ("for".equals(StringUtil.toLowerCase(attribute.getLocalName()))) { String id = attribute.getValue(); if (id != null) { myHolder.registerForValue(id); } } } } }
|
visitXmlTag
|
6,802
|
String () { return SHORT_NAME; }
|
getShortName
|
6,803
|
void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HtmlUtil.isHtmlTagContainingFile(tag)) { return; } final String tagName = StringUtil.toLowerCase(tag.getName()); if (ourElementsWithoutTitle.contains(tagName)) { final XmlAttribute title = tag.getAttribute(TITLE); if (title != null) { return; } List<LocalQuickFix> fixes = new ArrayList<>(); if (!ourElementsWithoutTitle.contains(tag.getName())) { fixes.add(new CreateNewLabelAction(tag.getName())); } if (holder.isOnTheFly()) { fixes.add(new InsertRequiredAttributeFix(tag, TITLE) { @Override public @NotNull String getText() { return HtmlToolsBundle.message("html.intention.insert.attribute", TITLE); } }); } InspectionUtils.RegisterProblem(tag, holder, fixes, HtmlToolsBundle.message("html.inspections.check.required.title"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } }
|
checkTag
|
6,804
|
String () { return HtmlToolsBundle.message("html.intention.insert.attribute", TITLE); }
|
getText
|
6,805
|
String () { return "HtmlRequiredTitleAttribute"; }
|
getShortName
|
6,806
|
String () { return "HtmlFormInputWithoutLabel"; }
|
getShortName
|
6,807
|
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); } } } }
|
checkTag
|
6,808
|
boolean (@NotNull XmlAttribute attribute) { XmlTag parent = attribute.getParent(); if (parent != null) { return attribute.equals(IdRefReference.getImplicitIdRefAttr(parent)); } return false; }
|
isImplicitIdAttribute
|
6,809
|
void (XmlTag tag, ProblemsHolder holder) { if (InjectedLanguageManager.getInstance(tag.getProject()).getInjectionHost(tag) != null) return; List<LocalQuickFix> fixes = new ArrayList<>(); Pair<PsiElement, PsiElement> pair = getNearestText(tag, new ForwardIterator()); if (pair != null) { fixes.add(new CreateLabelFromTextAction("html.inspections.create.label.from.text.after.action", false, tag.getName())); } pair = getNearestText(tag, new BackwardIterator()); if (pair != null) { fixes.add(new CreateLabelFromTextAction("html.inspections.create.label.from.text.before.action", true, tag.getName())); } fixes.add(new CreateNewLabelAction(tag.getName())); PsiElement toRegister = XmlTagUtil.getStartTagNameElement(tag); assert toRegister != null; InspectionManager manager = holder.getManager(); ProblemDescriptor descriptor = manager .createProblemDescriptor(toRegister, toRegister, HtmlToolsBundle.message("html.inspections.form.input.without.label"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, holder.isOnTheFly(), fixes.toArray(LocalQuickFix.EMPTY_ARRAY)); holder.registerProblem(descriptor); }
|
registerProblem
|
6,810
|
PsiElement (PsiElement element) { return element.getNextSibling(); }
|
getNext
|
6,811
|
PsiElement (PsiElement element) { return element.getPrevSibling(); }
|
getNext
|
6,812
|
void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HtmlUtil.isHtmlTagContainingFile(tag)) return; if (!tag.getName().equalsIgnoreCase(HEAD)) return; if (XmlCustomElementDescriptor.isCustomElement(tag)) return; final XmlTag[] subTags = tag.getSubTags(); long count = Arrays.stream(subTags).filter((element) -> element.getName().equalsIgnoreCase(TITLE)).count(); if (count > 0) return; List<LocalQuickFix> fixes = new ArrayList<>(); fixes.add(new CreateRequiredSubElement(tag.getOriginalElement(), TITLE)); InspectionUtils.RegisterProblem(tag, holder, fixes, HtmlToolsBundle.message("html.inspections.check.required.title.element"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }
|
checkTag
|
6,813
|
String () { return "HtmlRequiredTitleElement"; }
|
getShortName
|
6,814
|
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); }
|
checkTag
|
6,815
|
String () { return "HtmlRequiredLangAttribute"; }
|
getShortName
|
6,816
|
void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, @NotNull List<@NotNull LocalQuickFix> fixes, @InspectionMessage String text, @NotNull ProblemHighlightType severity) { PsiElement toRegister = XmlTagUtil.getStartTagNameElement(tag); if (toRegister == null) return; InspectionManager manager = holder.getManager(); ProblemDescriptor descriptor = manager .createProblemDescriptor(toRegister, toRegister, text, severity, holder.isOnTheFly(), fixes.toArray(LocalQuickFix.EMPTY_ARRAY)); holder.registerProblem(descriptor); }
|
RegisterProblem
|
6,817
|
void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HtmlUtil.isHtmlTagContainingFile(tag)) return; if (tag.getAttribute(ALT) != null) return; if (XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, ALT)) return; if (XmlCustomElementDescriptor.isCustomElement(tag)) return; if (!htmlTagsWithRequiredAltAttribute.contains(tag.getName())) return; //H36 if (tag.getName().equalsIgnoreCase("input")) { final XmlAttribute buttonWithImageType = tag.getAttribute("type"); if (buttonWithImageType != null && buttonWithImageType.getValue() != null) { if (!buttonWithImageType.getValue().equalsIgnoreCase("image")) return; } else { return; } } List<LocalQuickFix> fixes = new ArrayList<>(); if (isOnTheFly) fixes.add(new InsertRequiredAttributeFix(tag, ALT)); InspectionUtils.RegisterProblem(tag, holder, fixes, HtmlToolsBundle.message("html.inspections.check.required.alt"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }
|
checkTag
|
6,818
|
String () { return "HtmlRequiredAltAttribute"; }
|
getShortName
|
6,819
|
void (@NotNull XmlAttribute attribute, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (HtmlUtil.isHtmlTagContainingFile(attribute)) { if (!HtmlUtil.isHtml5Context(attribute)) { return; } XmlAttributeDescriptor descriptor = attribute.getDescriptor(); if (descriptor == null || descriptor.getClass() != HtmlAttributeDescriptorImpl.class) { return; } String name = ((HtmlAttributeDescriptorImpl)descriptor).isCaseSensitive() ? attribute.getName() : StringUtil.toLowerCase(attribute.getName()); MdnSymbolDocumentation documentation = getHtmlMdnDocumentation(attribute, null); boolean deprecatedInHtml5 = "align".equals(name) || (documentation != null && isDeprecatedOrObsolete(documentation.getApiStatus())); if (!deprecatedInHtml5) { return; } holder.registerProblem(attribute.getNameElement(), GlobalInspectionUtil.createInspectionMessage(HtmlToolsBundle.message("html.inspections.deprecated.attribute")), ProblemHighlightType.LIKE_DEPRECATED ); } }
|
checkAttribute
|
6,820
|
void (@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HtmlUtil.isHtmlTagContainingFile(tag)) return; final String tagName = StringUtil.toLowerCase(tag.getName()); if (!tagName.equalsIgnoreCase(TABLE)) return; List<LocalQuickFix> fixes = new ArrayList<>(); if (tag.getAttribute(SUMMARY) != null) return; if (isOnTheFly) { fixes.add(new InsertRequiredAttributeFix(tag, SUMMARY)); } InspectionUtils .RegisterProblem(tag, holder, fixes, HtmlToolsBundle.message("html.inspections.check.required.summary"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }
|
checkTag
|
6,821
|
String () { return super.getShortName(); }
|
getShortName
|
6,822
|
String () { return HtmlToolsBundle.message("html.inspections.create.new.label", myName); }
|
getFamilyName
|
6,823
|
void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { XmlTag myTag = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), XmlTag.class); if (myTag == null) return; XmlAttributeValue id = findIdValue(myTag); if (id != null) { PsiElement added = myTag.getParent().addBefore(createLabelFor(myTag, id), myTag); XmlToken token = XmlUtil.getTokenOfType(added, XmlTokenType.XML_END_TAG_START); if (token != null && token.isPhysical()) { PsiNavigateUtil.navigate(token); } } else { String text = "<label></label>"; XmlTag tag = createElementFromText(project, myTag, text); tag.addSubTag(myTag, true); tag.addBefore(createNewline(project), tag.getSubTags()[0]); tag.addAfter(createNewline(project), tag.getSubTags()[0]); myTag.getParent().addBefore(tag, myTag); myTag.delete(); } }
|
applyFix
|
6,824
|
XmlTag (@NotNull XmlTag place, @NotNull XmlAttributeValue id) { XmlTag tag = createElementFromText(place.getProject(), place, "<label for=\"x\"></label>"); //noinspection ConstantConditions tag.getAttribute("for").getValueElement().replace(id); return tag; }
|
createLabelFor
|
6,825
|
XmlText (@NotNull Project project) { return XmlElementFactory.getInstance(project).createTagFromText("<a>\n</a>").getValue().getTextElements()[0]; }
|
createNewline
|
6,826
|
XmlTag (Project project, XmlTag myTag, String text) { return myTag instanceof HtmlTag ? XmlElementFactory.getInstance(project).createHTMLTagFromText(text) : XmlElementFactory.getInstance(project).createXHTMLTagFromText(text); }
|
createElementFromText
|
6,827
|
String () { return HtmlToolsBundle.message(myBundleKey, myName); }
|
getFamilyName
|
6,828
|
void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement e = descriptor.getPsiElement(); if (e == null) return; XmlTag myTag = PsiTreeUtil.getParentOfType(e, XmlTag.class); if (myTag == null) return; Pair<PsiElement, PsiElement> pair = HtmlFormInputWithoutLabelInspection.getNearestText(myTag, myTextBeforeTag ? new HtmlFormInputWithoutLabelInspection.BackwardIterator() : new HtmlFormInputWithoutLabelInspection.ForwardIterator()); if (pair == null) return; final PsiElement myLeft = pair.first; final PsiElement myRight = pair.second; StringBuilder sb = new StringBuilder("<a>"); if (myTextBeforeTag) { for (PsiElement element = myLeft.getParent().getFirstChild(); element != null && element != myLeft; element = element.getNextSibling()) { sb.append(element.getText()); } } else { for (PsiElement element = myRight.getNextSibling(); element != null; element = element.getNextSibling()) { sb.append(element.getText()); if (element == element.getParent().getLastChild()) { break; } } } XmlTag tmpTag = CreateNewLabelAction.createElementFromText(project, myTag, sb.toString()); PsiElement anchor = null; for (PsiElement element : tmpTag.getChildren()) { if (element instanceof XmlText || element instanceof PsiComment) { if (anchor == null) { anchor = myLeft.getParent().replace(element); } else { anchor = myLeft.addAfter(element, anchor); } } } String id = CreateNewLabelAction.getId(myTag); if (id != null) { StringBuilder builder = new StringBuilder("\n<label for=\"").append(id).append("\">"); for (PsiElement element = myLeft; element != null; element = element.getNextSibling()) { builder.append(element.getText()); if (element == myRight) { break; } } builder.append("</label>"); XmlTag labelTag = CreateNewLabelAction.createElementFromText(project, myTag, builder.toString()); if (myTextBeforeTag) { myTag.getParent().addBefore(labelTag, myTag); } else { myTag.getParent().addAfter(labelTag, myTag); } } else { StringBuilder builder = new StringBuilder("\n<label>\n"); if (!myTextBeforeTag) { builder.append(myTag.getText()); builder.append("\n"); } for (PsiElement element = myLeft; element != null; element = element.getNextSibling()) { builder.append(element.getText()); if (element == myRight) { break; } } if (myTextBeforeTag) { builder.append("\n"); builder.append(myTag.getText()); } builder.append("\n</label>"); XmlTag tag = CreateNewLabelAction.createElementFromText(project, myTag, builder.toString()); myTag.replace(tag); } }
|
applyFix
|
6,829
|
String () { return HtmlToolsBundle.message("html.replace.tag.with.css.quickfix.text", myName); }
|
getName
|
6,830
|
String () { return getName(); }
|
getText
|
6,831
|
PsiElement[] (@NotNull Project project, boolean blocklevel) { final XmlFile xmlFile = HtmlTagReplaceUtil.genereateXmlFileWithSingleTag(project, blocklevel ? "div" : "span"); return HtmlTagReplaceUtil.getXmlNamesFromSingleTagFile(xmlFile); }
|
generateContainingElements
|
6,832
|
void (XmlTag tag, String name) { String s = tag.getAttributeValue(HtmlUtil.STYLE_ATTRIBUTE_NAME); String addString = Holder.ourTagToCssMap.get(name); if (s == null) { s = addString; } else { for (int i = s.length() - 1; i >= 0; i--) { if (!Character.isSpaceChar(s.charAt(i))) { if (s.charAt(i) != ';') { s += ';'; } break; } } s += " " + addString; } tag.setAttribute(HtmlUtil.STYLE_ATTRIBUTE_NAME, s); }
|
addCssAttribute
|
6,833
|
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); } }
|
applyFix
|
6,834
|
String () { return HtmlToolsBundle.message("html.replace.tag.with.css.quickfix.text", "font"); }
|
getName
|
6,835
|
PsiElement[] (@NotNull Project project, String tagName) { final XmlFile xmlFile = HtmlTagReplaceUtil.genereateXmlFileWithSingleTag(project, "span"); return HtmlTagReplaceUtil.getXmlNamesFromSingleTagFile(xmlFile); }
|
generateContainingElements
|
6,836
|
void (final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { PsiElement parent = descriptor.getPsiElement(); while (parent != null) { if (parent instanceof XmlTag && "font".equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) { break; } parent = parent.getParent(); } if (parent == null) { return; } final String name = StringUtil.toLowerCase(((XmlTag)parent).getLocalName()); XmlTag tag = (XmlTag)parent; PsiElement[] replacePsiElements = generateContainingElements(project, name); int cnt = 0; for (PsiElement element : tag.getChildren()) { if (element instanceof XmlToken token) { IElementType type = token.getTokenType(); if (type == XmlTokenType.XML_NAME) { token.replace(replacePsiElements[cnt++]); } } } StringBuilder style = new StringBuilder(); for (XmlAttribute attribute : tag.getAttributes()) { if ("face".equals(attribute.getName())) { String value = attribute.getValue(); attribute.delete(); style.append("font-family: "); style.append(value); style.append("; "); } else if ("color".equals(attribute.getName())) { String value = attribute.getValue(); attribute.delete(); style.append("color: "); style.append(value); style.append("; "); } else if ("size".equals(attribute.getName())) { String value = attribute.getValue(); attribute.delete(); if (Holder.ourSizesMap.containsKey(value)) { style.append("font-size: "); style.append(Holder.ourSizesMap.get(value)); style.append("; "); } } } if (style.length() != 0) { boolean found = false; for (XmlAttribute attribute : tag.getAttributes()) { if (HtmlUtil.STYLE_ATTRIBUTE_NAME.equals(attribute.getName())) { found = true; attribute.setValue(attribute.getValue() + " " + style); break; } } if (!found) { tag.setAttribute(HtmlUtil.STYLE_ATTRIBUTE_NAME, style.toString()); } } }
|
applyFix
|
6,837
|
String () { return HtmlToolsBundle.message("html.replace.tag.with.another.quickfix.text", myName, Holder.ourTagToNewTagMap.get(myName)); }
|
getName
|
6,838
|
PsiElement[] (@NotNull Project project, String tagName) { final XmlFile xmlFile = HtmlTagReplaceUtil.genereateXmlFileWithSingleTag(project, Holder.ourTagToNewTagMap.get(tagName)); return HtmlTagReplaceUtil.getXmlNamesFromSingleTagFile(xmlFile); }
|
generateContainingElements
|
6,839
|
void (final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { PsiElement parent = descriptor.getPsiElement(); while (parent != null) { if (parent instanceof XmlTag && myName.equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) { break; } parent = parent.getParent(); } if (parent == null) { return; } final String name = StringUtil.toLowerCase(((XmlTag)parent).getLocalName()); XmlTag tag = (XmlTag)parent; PsiElement[] replacePsiElements = generateContainingElements(project, name); int cnt = 0; for (PsiElement element : tag.getChildren()) { if (element instanceof XmlToken token) { IElementType type = token.getTokenType(); if (type == XmlTokenType.XML_NAME) { token.replace(replacePsiElements[cnt++]); } } } }
|
applyFix
|
6,840
|
XmlFile (@NotNull Project project, String filetext) { return (XmlFile)PsiFileFactory.getInstance(project).createFileFromText("dummy.xml", XMLLanguage.INSTANCE, filetext); }
|
generateXmlFile
|
6,841
|
XmlFile (@NotNull Project project, String tagname) { @NonNls String filetext = "<" + tagname + "></" + tagname + ">"; return generateXmlFile(project, filetext); }
|
genereateXmlFileWithSingleTag
|
6,842
|
PsiElement[] (XmlFile xmlFile) { XmlTag tag = xmlFile.getDocument().getRootTag(); assert tag != null; PsiElement[] answer = new PsiElement[2]; int cnt = 0; for (PsiElement child : tag.getChildren()) { if (child instanceof XmlToken) { IElementType type = ((XmlToken)child).getTokenType(); if (type == XmlTokenType.XML_NAME) { answer[cnt++] = child; } } } return answer; }
|
getXmlNamesFromSingleTagFile
|
6,843
|
String () { return HtmlToolsBundle.message("html.replace.tag.with.another.quickfix.text", "applet", "object"); }
|
getName
|
6,844
|
PsiElement[] (@NotNull Project project, String tagName) { final XmlFile xmlFile = HtmlTagReplaceUtil.genereateXmlFileWithSingleTag(project, "object"); return HtmlTagReplaceUtil.getXmlNamesFromSingleTagFile(xmlFile); }
|
generateContainingElements
|
6,845
|
void (final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { PsiElement parent = descriptor.getPsiElement(); while (parent != null) { if (parent instanceof XmlTag && "applet".equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) { break; } parent = parent.getParent(); } if (parent == null) { return; } final String name = StringUtil.toLowerCase(((XmlTag)parent).getLocalName()); XmlTag tag = (XmlTag)parent; PsiElement[] replacePsiElements = generateContainingElements(project, name); int cnt = 0; for (PsiElement element : tag.getChildren()) { if (element instanceof XmlToken token) { IElementType type = token.getTokenType(); if (type == XmlTokenType.XML_NAME) { token.replace(replacePsiElements[cnt++]); } } } for (XmlAttribute attribute : tag.getAttributes()) { String attName = attribute.getName(); if (!"object".equals(attName) && !Holder.ourObjectAttributes.contains(attName)) { final String attributeValue = attribute.getValue(); String value = attributeValue != null ? attributeValue.trim() : ""; if ("code".equals(attName) && value.endsWith(".class")) { value = value.substring(0, value.length() - ".class".length()); } XmlFile file = HtmlTagReplaceUtil.generateXmlFile(project, "<param name=\""+ attName + "\" value=\""+value+"\" />"); PsiElement element = file.getDocument().getRootTag(); assert element != null; for (PsiElement psiElement : tag.getChildren()) { if (psiElement instanceof XmlToken) { IElementType type = ((XmlToken)psiElement).getTokenType(); if (type == XmlTokenType.XML_TAG_END) { tag.add(element); break; } } } if (!"name".equals(attName)) { attribute.delete(); } } else if ("object".equals(attName)){ attribute.setName("data"); } } StringBuilder builder = new StringBuilder(); builder.append("<a>"); builder.append("\n<!--[if !IE]> -->"); builder.append("<object"); for (XmlAttribute attribute : tag.getAttributes()) { if (!"classid".equals(StringUtil.toLowerCase(attribute.getName())) && !"codebase".equals(StringUtil.toLowerCase(attribute.getName()))) { builder.append(" "); builder.append(StringUtil.toLowerCase(attribute.getName())); builder.append("=\""); builder.append(attribute.getValue()); builder.append("\""); } } builder.append(">"); boolean contentStarted = false; for (PsiElement element : tag.getChildren()) { if (element instanceof XmlToken) { if (((XmlToken)element).getTokenType() == XmlTokenType.XML_TAG_END) { contentStarted = true; } else if (((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) { break; } } else if (contentStarted) { builder.append(element.getText()); } } builder.append("</object>"); builder.append("\n<!-- <![endif]-->\n"); builder.append("</a>"); XmlFile file = HtmlTagReplaceUtil.generateXmlFile(project, builder.toString()); XmlTag additionalTagElements = file.getDocument().getRootTag(); assert additionalTagElements != null; for (PsiElement element : tag.getChildren()) { if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) { contentStarted = false; for (PsiElement psiElement : additionalTagElements.getChildren()) { if (psiElement instanceof XmlToken) { if (((XmlToken)psiElement).getTokenType() == XmlTokenType.XML_TAG_END) { contentStarted = true; } else if (((XmlToken)psiElement).getTokenType() == XmlTokenType.XML_END_TAG_START) { break; } } else if (contentStarted) { if (psiElement instanceof XmlTag) { ((XmlTag)psiElement).setAttribute("type", "application/x-java-applet"); } tag.addBefore(psiElement, element); } } } } tag.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"); tag.setAttribute("codebase", "http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"); }
|
applyFix
|
6,846
|
boolean (@NotNull PsiFile file) { // Shouldn't work for inherited languages like Vue or Angular2HTML return file.getLanguage() == HTMLLanguage.INSTANCE || file.getLanguage() == XHTMLLanguage.INSTANCE; }
|
isAvailableForFile
|
6,847
|
void (final String includePath, final XmlTagChild first, final XmlTagChild last) { ApplicationManager.getApplication().runWriteAction(() -> { final XmlTag parentTag = first.getParentTag(); LOG.assertTrue(parentTag != null); try { final XmlElementDescriptor descriptor = parentTag.getDescriptor(); LOG.assertTrue(descriptor != null); final @NonNls String name = descriptor.getName(); if (HtmlUtil.SCRIPT_TAG_NAME.equals(name)) { parentTag.setAttribute("src", includePath); LOG.assertTrue(first.getParent() == parentTag); parentTag.deleteChildRange(first, last); } else if (HtmlUtil.STYLE_TAG_NAME.equals(name)) { final XmlTag linkTag = parentTag.createChildTag("link", parentTag.getNamespace(), null, false); linkTag.setAttribute("href", includePath); linkTag.setAttribute("rel", "stylesheet"); final String type = parentTag.getAttributeValue("type"); if (type != null) { linkTag.setAttribute("type", type); } final String media = parentTag.getAttributeValue("media"); if (media != null) { linkTag.setAttribute("media", media); } parentTag.replace(linkTag); } } catch (IncorrectOperationException e) { LOG.error(e); } }); }
|
doReplaceRange
|
6,848
|
boolean (final XmlTagChild first, final XmlTagChild last) { final Language language = first.getLanguage(); if (first != last || Language.findInstance(HTMLLanguage.class).equals(language) || Language.findInstance(XHTMLLanguage.class).equals(language) ) { return false; } final XmlTag parentTag = first.getParentTag(); return parentTag != null && isAvailableOnDescriptor(parentTag.getDescriptor()); }
|
verifyChildRange
|
6,849
|
boolean (@Nullable XmlElementDescriptor descriptor) { if (descriptor == null) return false; final @NonNls String name = descriptor.getName(); return HtmlUtil.STYLE_TAG_NAME.equals(name) || HtmlUtil.SCRIPT_TAG_NAME.equals(name); }
|
isAvailableOnDescriptor
|
6,850
|
boolean (@NotNull PsiErrorElement element) { PsiFile containingFile = element.getContainingFile(); return containingFile.getLanguage() != XHTMLLanguage.INSTANCE || !(InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile) instanceof PsiComment) || !element.getErrorDescription().contains("Multiple root tags"); }
|
shouldHighlightErrorElement
|
6,851
|
boolean () { return true; }
|
isEnabledByDefault
|
6,852
|
String () { return myFamilyName; }
|
getFamilyName
|
6,853
|
void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final XmlAttributeValue value = (XmlAttributeValue)descriptor.getPsiElement(); if (value == null) return; try { final PsiReference[] refs = value.getReferences(); if (refs.length != 1) return; ElementManipulators.handleContentChange(value, refs[0].getRangeInElement(), myAdequateValue); } catch (IncorrectOperationException e) { LOG.error(e); } }
|
applyFix
|
6,854
|
PsiElementVisitor (final @NotNull ProblemsHolder holder, boolean isOnTheFly) { return new XmlElementVisitor() { @Override public void visitXmlAttribute(@NotNull XmlAttribute attribute) { XmlTag parent = attribute.getParent(); if (!(parent instanceof HtmlTag) || XmlHighlightVisitor.isInjectedWithoutValidation(parent)) { return; } String name = attribute.getName(); if (HtmlReferenceProvider.SizeReference.HEIGHT_ATTR_NAME.equalsIgnoreCase(name) || HtmlReferenceProvider.SizeReference.WIDTH_ATTR_NAME.equalsIgnoreCase(name)) { final XmlAttributeValue value = attribute.getValueElement(); if (value != null && value.getTextLength() > 0) { final PsiReference[] refs = value.getReferences(); final boolean isHeight = HtmlReferenceProvider.SizeReference.HEIGHT_ATTR_NAME.equalsIgnoreCase(name); if (refs.length == 1 && refs[0] instanceof HtmlReferenceProvider.SizeReference sizeReference && refs[0].getRangeInElement().getLength() >= 2 // avoid errors on concatenations ) { PsiElement element = sizeReference.resolve(); if (element == null) { final ImageInfoReader.Info imageInfo = sizeReference.getImageInfo(); if (imageInfo == null || imageInfo.height == 0 || imageInfo.width == 0 || imageInfo.isSvg()) { return; } final String adequateValue = String.valueOf(isHeight ? imageInfo.height : imageInfo.width); final String message = HtmlToolsBundle.message( isHeight ? "html.inspections.check.image.height.fix.message" : "html.inspections.check.image.width.fix.message", adequateValue); final MyFix fix = new MyFix(message, HtmlToolsBundle.message("html.inspections.check.image.fix.family"), adequateValue); holder.registerProblem(value, HtmlToolsBundle.message( isHeight ? "html.inspections.check.image.height.message" : "html.inspections.check.image.width.message", adequateValue), fix); } } } } } }; }
|
buildVisitor
|
6,855
|
ElementFilter () { return new ElementFilter() { @Override public boolean isAcceptable(Object _element, PsiElement context) { PsiElement element = (PsiElement)_element; PsiFile file = element.getContainingFile(); return (HtmlUtil.hasHtml(file) || HtmlUtil.supportsXmlTypedHandlers(file)) && isAcceptableAttributeValue(element); } @Override public boolean isClassAcceptable(Class hintClass) { return true; } }; }
|
getFilter
|
6,856
|
boolean (Object _element, PsiElement context) { PsiElement element = (PsiElement)_element; PsiFile file = element.getContainingFile(); return (HtmlUtil.hasHtml(file) || HtmlUtil.supportsXmlTypedHandlers(file)) && isAcceptableAttributeValue(element); }
|
isAcceptable
|
6,857
|
boolean (Class hintClass) { return true; }
|
isClassAcceptable
|
6,858
|
boolean (PsiElement element) { final PsiElement parent = element.getParent(); if (parent instanceof XmlAttribute xmlAttribute) { final @NonNls String attrName = xmlAttribute.getName(); XmlTag tag = xmlAttribute.getParent(); if (tag == null) return false; final @NonNls String tagName = tag.getName(); return ( attrName.equalsIgnoreCase(SRC_ATTR_NAME) && (tagName.equalsIgnoreCase(SizeReference.IMAGE_TAG_NAME) || tagName.equalsIgnoreCase(HtmlUtil.SCRIPT_TAG_NAME) || tagName.equalsIgnoreCase("frame") || tagName.equalsIgnoreCase("iframe") || tagName.equalsIgnoreCase("video") || tagName.equalsIgnoreCase("audio") || tagName.equalsIgnoreCase("track") || tagName.equalsIgnoreCase("source") || tagName.equalsIgnoreCase("embed") || tagName.equalsIgnoreCase("input") && tag.getAttributeValue("type") != null && "image".equalsIgnoreCase(tag.getAttributeValue("type")) ) ) || ( attrName.equalsIgnoreCase(HREF_ATTRIBUTE_NAME) && ( tagName.equalsIgnoreCase("a") || tagName.equalsIgnoreCase("area") || tagName.equalsIgnoreCase("link") ) ) || ( attrName.equalsIgnoreCase(USEMAP_ATTR_NAME) && (tagName.equalsIgnoreCase(SizeReference.IMAGE_TAG_NAME) || tagName.equalsIgnoreCase("object")) ) || ( attrName.equalsIgnoreCase("action") && tagName.equalsIgnoreCase("form") ) || attrName.equalsIgnoreCase("background") || ( ( attrName.equalsIgnoreCase(NAME_ATTR_LOCAL_NAME) || attrName.equalsIgnoreCase(HtmlUtil.ID_ATTRIBUTE_NAME) || attrName.equalsIgnoreCase(HtmlUtil.CLASS_ATTRIBUTE_NAME) ) && tag.getNamespacePrefix().length() == 0 ) || ( (attrName.equalsIgnoreCase(SizeReference.WIDTH_ATTR_NAME) || attrName.equalsIgnoreCase(SizeReference.HEIGHT_ATTR_NAME) ) && (tagName.equalsIgnoreCase(SizeReference.IMAGE_TAG_NAME)) ) || (attrName.equalsIgnoreCase(ContentTypeReference.TYPE_ATTR_NAME) && (tagName.equalsIgnoreCase(HtmlUtil.STYLE_TAG_NAME) || tagName.equalsIgnoreCase(HtmlUtil.SCRIPT_TAG_NAME) ) ) || (attrName.equalsIgnoreCase(ColorReference.BG_COLOR_ATTR_NAME) && ColorReference.ourBgColorTagNames.contains(StringUtil.toLowerCase(tagName)) ) || ( attrName.equalsIgnoreCase(ColorReference.COLOR_ATTR_NAME) && (tagName.equalsIgnoreCase("basefont") || tagName.equalsIgnoreCase("font") ) ) || ( tagName.equalsIgnoreCase("body") && (attrName.equalsIgnoreCase(ColorReference.TEXT_ATTR_NAME) || attrName.equalsIgnoreCase(ColorReference.LINK_ATTR_NAME) || attrName.equalsIgnoreCase(ColorReference.VLINK_ATTR_NAME) || attrName.equalsIgnoreCase(ColorReference.ALINK_ATTR_NAME) ) ) || (tagName.equalsIgnoreCase("label") && attrName.equalsIgnoreCase(FOR_ATTR_NAME) ) || (attrName.equalsIgnoreCase(MicrodataUtil.ITEM_REF) && tag.getAttribute(MicrodataUtil.ITEM_SCOPE) != null ) || (attrName.equalsIgnoreCase("data") && tagName.equalsIgnoreCase("object") )|| (attrName.equalsIgnoreCase("poster") && tagName.equalsIgnoreCase("video") )|| (attrName.equalsIgnoreCase("srcset") && (tagName.equalsIgnoreCase(SizeReference.IMAGE_TAG_NAME) || tagName.equals("source")) )|| (attrName.equalsIgnoreCase(LABELLEDBY)) ; } return false; }
|
isAcceptableAttributeValue
|
6,859
|
FileType[] (@Nullable String rel) { if (rel == null) return null; for (String type : rel.split(" ")) { if ("stylesheet".equalsIgnoreCase(type)) { return findFileType("text/css"); } if (type.contains("icon") || type.contains("image")) { return IMAGE_FILE_TYPES; } } return null; }
|
findFileTypeByRel
|
6,860
|
FileType[] (@Nullable String mimeType) { final Collection<Language> languages = Language.findInstancesByMimeType(mimeType != null ? mimeType.trim() : null); FileType fileType = ContainerUtil.find(FileTypeManager.getInstance().getRegisteredFileTypes(), type -> type instanceof LanguageFileType && languages.contains(((LanguageFileType)type).getLanguage())); return fileType == null ? null : new FileType[]{fileType}; }
|
findFileType
|
6,861
|
String[] () { return new String[] {SRC_ATTR_NAME, HREF_ATTRIBUTE_NAME, USEMAP_ATTR_NAME, "action", "background", "width", "height", "type", "bgcolor", "color", "vlink", "link", "alink", "text", "name", HtmlUtil.ID_ATTRIBUTE_NAME, HtmlUtil.CLASS_ATTRIBUTE_NAME, FOR_ATTR_NAME, MicrodataUtil.ITEM_REF, "data", "poster", "srcset", LABELLEDBY }; }
|
getAttributeValues
|
6,862
|
boolean () { return true; }
|
isSoft
|
6,863
|
int (@Nullable String value, @NotNull XmlElement context) { if (value == null) { return 0; } if (!HtmlUtil.isHtml5Context(context)) { value = StringUtil.trimEnd(value, "px").trim(); } return StringUtil.parseInt(value, 0); }
|
getSizeValue
|
6,864
|
boolean () { return true; }
|
isSoft
|
6,865
|
boolean (final @NotNull PsiElement element) { if (element instanceof XmlTag) { String forValue = ((XmlTag)element).getAttributeValue(IdReferenceProvider.FOR_ATTR_NAME); if (forValue != null) { result.add(forValue); } } return true; }
|
execute
|
6,866
|
boolean () { return true; }
|
isSoft
|
6,867
|
boolean () { return true; }
|
isSoft
|
6,868
|
boolean (@NotNull Project project, Editor editor, PsiFile file) { final int offset = editor.getCaretModel().getOffset(); if (isAvailable(getTag(file, offset))) { return true; } if (offset > 0 && isAvailable(getTag(file, offset - 1))) { myUseElementToTheLeft = true; return true; } return false; }
|
isAvailable
|
6,869
|
boolean (@Nullable XmlTag tag) { if (tag == null) { return false; } ImageInfo imageInfo = getImageInfo(tag); if (imageInfo == null || imageInfo.height == 0 || imageInfo.width == 0) { return false; } final String widthValue = tag.getAttributeValue(HtmlReferenceProvider.SizeReference.WIDTH_ATTR_NAME); final String heightValue = tag.getAttributeValue(HtmlReferenceProvider.SizeReference.HEIGHT_ATTR_NAME); setText(widthValue != null || heightValue != null ? HtmlToolsBundle.message("html.intention.update.image.size") : HtmlToolsBundle.message("html.intention.insert.image.size")); return imageInfo.width != HtmlReferenceProvider.SizeReference.getSizeValue(widthValue, tag) || imageInfo.height != HtmlReferenceProvider.SizeReference.getSizeValue(heightValue, tag); }
|
isAvailable
|
6,870
|
void (@NotNull PsiReferenceRegistrar registrar) { HtmlReferenceProvider provider = new HtmlReferenceProvider(); String[] htmlAttrs = HtmlReferenceProvider.getAttributeValues(); ElementFilter htmlFilter = HtmlReferenceProvider.getFilter(); XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, htmlAttrs, htmlFilter, false, provider); XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[] {"content"}, new ScopeFilter( new ParentElementFilter( new AndFilter(XmlTagFilter.INSTANCE, new XmlTextFilter("meta")), 2 ) ), true, new HtmlHttpEquivEncodingReferenceProvider()); }
|
registerReferenceProviders
|
6,871
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableColumnAdder.addColumn(project, editor, file, false); }
|
invoke
|
6,872
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,873
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableColumnAdder.isActionAvailable(editor, file); }
|
isValidForFile
|
6,874
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableColumnAdder.addColumn(project, editor, file, true); }
|
invoke
|
6,875
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,876
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableColumnAdder.isActionAvailable(editor, file); }
|
isValidForFile
|
6,877
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.RIGHT); }
|
invoke
|
6,878
|
boolean () { return false; }
|
startInWriteAction
|
6,879
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,880
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableCellNavigator.isActionAvailable(editor, file); }
|
isValidForFile
|
6,881
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.UP); }
|
invoke
|
6,882
|
boolean () { return false; }
|
startInWriteAction
|
6,883
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,884
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableCellNavigator.isActionAvailable(editor, file); }
|
isValidForFile
|
6,885
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.LEFT); }
|
invoke
|
6,886
|
boolean () { return false; }
|
startInWriteAction
|
6,887
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,888
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableCellNavigator.isActionAvailable(editor, file); }
|
isValidForFile
|
6,889
|
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.DOWN); }
|
invoke
|
6,890
|
boolean () { return false; }
|
startInWriteAction
|
6,891
|
CodeInsightActionHandler () { return myHandler; }
|
getHandler
|
6,892
|
boolean (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { return TableCellNavigator.isActionAvailable(editor, file); }
|
isValidForFile
|
6,893
|
void () { myFixture.configureByText(HtmlFileType.INSTANCE, """ <!doctype html> <html lang='en'> <head> <meta charset='UTF-8'> <meta content='width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' name='viewport'> <meta http-equiv='X-UA-Compatible' content='ie=edge'> <title>Document</title> </head> <body> <div> <div id="hello"></div> </div> </body> </html> """); doTest("hello", "hello (aaa.html)"); }
|
testSimple
|
6,894
|
void (@NotNull String name, String @NotNull ... expectedItems) { ((PsiManagerEx)myFixture.getPsiManager()).setAssertOnFileLoadingFilter(VirtualFileFilter.ALL, myFixture.getTestRootDisposable()); GotoSymbolModel2 model = new GotoSymbolModel2(myFixture.getProject(), myFixture.getTestRootDisposable()); assertContainsElements(Arrays.asList(model.getNames(false)), name); final ArrayList<String> actual = new ArrayList<>(); for (Object o : model.getElementsByName(name, false, "")) { if (o instanceof NavigationItem) { final ItemPresentation presentation = ((NavigationItem)o).getPresentation(); assertNotNull(presentation); actual.add(presentation.getPresentableText() + " " + presentation.getLocationString()); } } assertSameElements(actual, expectedItems); }
|
doTest
|
6,895
|
void () { myFixture.configureByText("test.html", "<p id=<caret>\""); try { myFixture.getReferenceAtCaretPosition(); } catch (Exception e) { fail(); } }
|
testXHtmlCompletion
|
6,896
|
String () { return BASE_PATH + "/actions"; }
|
getBasePath
|
6,897
|
String () { return PathManager.getCommunityHomePath() + "/plugins/htmltools/testData/inspections"; }
|
getTestDataPath
|
6,898
|
void () { configureByFile(BASE_PATH + "/html_deptag5.xml"); final List<IntentionAction> list = getAvailableActions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, "Replace font tag with CSS"); assertNull(action); }
|
testXml
|
6,899
|
void () { configureByFile(BASE_PATH + "/html_deptag5.xhtml"); final List<IntentionAction> list = getAvailableActions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, "Replace menu tag with ul tag"); assertNull(action); }
|
testFitMenu
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.