check only html attributes and their case-sensitivity (WEB-38718, WEB-40047)

GitOrigin-RevId: 00d9e72224fc0433b68c80577d436341ef3f16fa
This commit is contained in:
Dennis Ushakov
2019-07-23 17:44:15 +03:00
committed by intellij-monorepo-bot
parent fa1f5b9c73
commit 6e8cf69934
3 changed files with 15 additions and 3 deletions
@@ -16,6 +16,8 @@ import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.FakePsiElement;
import com.intellij.psi.impl.source.html.dtd.HtmlAttributeDescriptorImpl;
import com.intellij.psi.impl.source.html.dtd.HtmlElementDescriptorImpl;
import com.intellij.psi.impl.source.xml.SchemaPrefix;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
@@ -254,7 +256,10 @@ public class HtmlDocumentationProvider implements DocumentationProvider, Externa
if (element != null && LookupManager.getInstance(element.getProject()).getActiveLookup() == null) {
XmlAttribute attribute = ReadAction.compute(() -> PsiTreeUtil.getParentOfType(element, XmlAttribute.class, true));
if (attribute != null) {
return HtmlCompatibilityData.getAttributeData(attribute.getParent(), attribute.getName());
XmlAttributeDescriptor descriptor = attribute.getDescriptor();
String name = descriptor instanceof HtmlAttributeDescriptorImpl && !((HtmlAttributeDescriptorImpl)descriptor).isCaseSensitive() ?
StringUtil.toLowerCase(attribute.getName()) : attribute.getName();
return HtmlCompatibilityData.getAttributeData(attribute.getParent(), name);
}
else if (element.getParent() instanceof XmlTag) {
return HtmlCompatibilityData.getTagData((XmlTag)element.getParent());
@@ -265,7 +270,10 @@ public class HtmlDocumentationProvider implements DocumentationProvider, Externa
} else {
XmlTag tag = ReadAction.compute(() -> PsiTreeUtil.getParentOfType(element, XmlTag.class, true));
if (tag != null) {
return HtmlCompatibilityData.getAttributeData(tag, entity.name);
XmlElementDescriptor descriptor = tag.getDescriptor();
String name = descriptor instanceof HtmlElementDescriptorImpl && !((HtmlElementDescriptorImpl)descriptor).isCaseSensitive() ?
StringUtil.toLowerCase(entity.name) : entity.name;
return HtmlCompatibilityData.getAttributeData(tag, name);
}
}
return null;
@@ -224,4 +224,8 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl {
public String toString() {
return myDelegate.toString();
}
public boolean isCaseSensitive() {
return myCaseSensitive;
}
}
@@ -103,7 +103,7 @@ public class HtmlCompatibilityData {
public static Map getAttributeData(@Nullable XmlTag tag, String attributeName) {
Object data = getTagData(tag);
if (data != null) {
Object attributeData = ((Map)data).get(StringUtil.toLowerCase(attributeName));
Object attributeData = ((Map)data).get(attributeName);
if (attributeData != null) return (Map)attributeData;
}
if (ourGlobalAttributesCache.get() == null) {