From 2ca501b2cdcf7987dba6c94398e4179371a14002 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Thu, 5 Nov 2015 20:31:46 +0300 Subject: [PATCH] CSS: do not cache custom selectors --- .../src/com/intellij/xml/util/HtmlUtil.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java index 6a393d7a374f..c479ceba74be 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java @@ -318,22 +318,7 @@ public class HtmlUtil { final String tagName = tokenizer.nextToken(); if (tagName.length() == 0) continue; - descriptors[index++] = new XmlElementDescriptorImpl(null) { - @Override - public String getName(PsiElement context) { - return tagName; - } - - @Override - public String getDefaultName() { - return tagName; - } - - @Override - public boolean allowElementsFromNamespace(final String namespace, final XmlTag context) { - return true; - } - }; + descriptors[index++] = new CustomXmlTagDescriptor(tagName); } return descriptors; @@ -684,4 +669,28 @@ public class HtmlUtil { public static boolean isScriptTag(@Nullable XmlTag tag) { return tag != null && tag.getLocalName().equalsIgnoreCase(SCRIPT_TAG_NAME); } + + public static class CustomXmlTagDescriptor extends XmlElementDescriptorImpl { + private final String myTagName; + + public CustomXmlTagDescriptor(String tagName) { + super(null); + myTagName = tagName; + } + + @Override + public String getName(PsiElement context) { + return myTagName; + } + + @Override + public String getDefaultName() { + return myTagName; + } + + @Override + public boolean allowElementsFromNamespace(final String namespace, final XmlTag context) { + return true; + } + } }