diff --git a/plugins/htmltools/testData/completion/AdditionalHtmlAttributesInsertedByCompletion2_after.html b/plugins/htmltools/testData/completion/AdditionalHtmlAttributesInsertedByCompletion2_after.html
index 0c4fce812ac5..e4349970315f 100644
--- a/plugins/htmltools/testData/completion/AdditionalHtmlAttributesInsertedByCompletion2_after.html
+++ b/plugins/htmltools/testData/completion/AdditionalHtmlAttributesInsertedByCompletion2_after.html
@@ -1 +1 @@
-
-
+
\ No newline at end of file
diff --git a/plugins/htmltools/testData/completion/AdditionalHtmlTagsInsertedByCompletion_after.html b/plugins/htmltools/testData/completion/AdditionalHtmlTagsInsertedByCompletion_after.html
index 4a1a8f362085..613d304fc031 100644
--- a/plugins/htmltools/testData/completion/AdditionalHtmlTagsInsertedByCompletion_after.html
+++ b/plugins/htmltools/testData/completion/AdditionalHtmlTagsInsertedByCompletion_after.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/plugins/htmltools/testData/highlighting/CustomTagHighlighting.html b/plugins/htmltools/testData/highlighting/CustomTagHighlighting.html
index 5571214467c9..bae13023ff9a 100644
--- a/plugins/htmltools/testData/highlighting/CustomTagHighlighting.html
+++ b/plugins/htmltools/testData/highlighting/CustomTagHighlighting.html
@@ -1,2 +1,3 @@
<custom-tag>hellocustom-tag>
+<custom2-tag>hellocustom2-tag>
hello
\ No newline at end of file
diff --git a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/completion/HtmlCompletionTest.java b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/completion/HtmlCompletionTest.java
index f92f3cf1d9da..9e3faa610420 100644
--- a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/completion/HtmlCompletionTest.java
+++ b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/completion/HtmlCompletionTest.java
@@ -338,12 +338,8 @@ public class HtmlCompletionTest extends BasePlatformTestCase {
public void testAdditionalHtmlTagsInsertedByCompletion() throws Exception {
final HtmlUnknownTagInspection inspection = new HtmlUnknownTagInspection();
- String additionalEntries = inspection.getAdditionalEntries();
- if (additionalEntries.length() > 0) {
- additionalEntries += ",";
- }
- inspection.updateAdditionalEntries(additionalEntries + "zzz");
+ inspection.updateAdditionalEntries("zZz", getTestRootDisposable());
doTestWithHtmlInspectionEnabled("", inspection);
doTestWithHtmlInspectionEnabled("2", inspection);
@@ -351,12 +347,8 @@ public class HtmlCompletionTest extends BasePlatformTestCase {
public void testAdditionalHtmlAttributesInsertedByCompletion() throws Exception {
final HtmlUnknownAttributeInspection inspection = new HtmlUnknownAttributeInspection();
- String additionalEntries = inspection.getAdditionalEntries();
- if (additionalEntries.length() > 0) {
- additionalEntries += ",";
- }
- inspection.updateAdditionalEntries(additionalEntries + "zzz");
+ inspection.updateAdditionalEntries("zZz", getTestRootDisposable());
doTestWithHtmlInspectionEnabled("2", inspection);
doTestWithHtmlInspectionEnabled("", inspection);
diff --git a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/HtmlHighlightingTest.java b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/HtmlHighlightingTest.java
index 9b2ac54f117c..dcd3e0b86bed 100644
--- a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/HtmlHighlightingTest.java
+++ b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/HtmlHighlightingTest.java
@@ -855,18 +855,12 @@ public class HtmlHighlightingTest extends BasePlatformTestCase {
public void testCustomTagHighlighting() {
HtmlUnknownTagInspection inspection = new HtmlUnknownTagInspection();
- String before = inspection.getAdditionalEntries();
- inspection.updateAdditionalEntries("custom-tag,custom2-tag");
- try {
- myFixture.enableInspections(inspection);
+ inspection.updateAdditionalEntries("custom-tag,custom2-TAG", getTestRootDisposable());
+ myFixture.enableInspections(inspection);
- HighlightTestInfo info = myFixture.testFile(getTestName(false) + ".html");
- info.checkSymbolNames();
- info.test();
- }
- finally {
- inspection.updateAdditionalEntries(before);
- }
+ HighlightTestInfo info = myFixture.testFile(getTestName(false) + ".html");
+ info.checkSymbolNames();
+ info.test();
}
private void doTestWebLinks(boolean startTestingLocalServer) throws Exception {
diff --git a/xml/tests/src/com/intellij/codeInsight/template/emmet/HtmlEmmetAbbreviationTest.java b/xml/tests/src/com/intellij/codeInsight/template/emmet/HtmlEmmetAbbreviationTest.java
index 4d4aa33ba8dc..f31797ed979b 100644
--- a/xml/tests/src/com/intellij/codeInsight/template/emmet/HtmlEmmetAbbreviationTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/template/emmet/HtmlEmmetAbbreviationTest.java
@@ -55,7 +55,7 @@ public class HtmlEmmetAbbreviationTest extends EmmetAbbreviationTestSuite {
@Override
protected void setUp(@NotNull Project project) throws Exception {
- super.setUp(project);
+ super.setUp(project);
final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(project);
TemplateContextType contextType = TemplateContextTypes.getByClass(HtmlTextContextType.class);
@@ -222,10 +222,8 @@ public class HtmlEmmetAbbreviationTest extends EmmetAbbreviationTestSuite {
addTestWithInit("input[title]", "", null);
addTestWithInit("input[title]", "", (fixture, testRootDisposable) -> {
final HtmlUnknownBooleanAttributeInspection inspection = new HtmlUnknownBooleanAttributeInspection();
- final String oldValue = inspection.getAdditionalEntries();
- inspection.updateAdditionalEntries("title");
+ inspection.updateAdditionalEntries("title", testRootDisposable);
fixture.enableInspections(inspection);
- Disposer.register(testRootDisposable, () -> inspection.updateAdditionalEntries(oldValue));
});
}
diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownElementInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownElementInspection.java
index 40da7c3a5fe5..4759b5103de0 100644
--- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownElementInspection.java
+++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownElementInspection.java
@@ -20,12 +20,15 @@ import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.util.InspectionMessage;
import com.intellij.lang.ASTNode;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlChildRole;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.StringTokenizer;
@@ -43,7 +46,7 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
final StringTokenizer tokenizer = new StringTokenizer(properties, ",");
while (tokenizer.hasMoreTokens()) {
- result.add(StringUtil.toLowerCase(tokenizer.nextToken()).trim());
+ result.add(tokenizer.nextToken());
}
return result;
@@ -64,13 +67,13 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
}
}
- protected boolean isCustomValue(@NotNull final String value) {
- return myValues.contains(StringUtil.toLowerCase(value));
+ protected boolean isCustomValue(@NotNull String value) {
+ return ContainerUtil.exists(myValues, val -> StringUtil.equalsIgnoreCase(val, value));
}
@Override
public void addEntry(@NotNull final String text) {
- final String s = StringUtil.toLowerCase(text.trim());
+ final String s = text.trim();
if (!isCustomValue(s)) {
myValues.add(s);
}
@@ -89,8 +92,14 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
return StringUtil.join(myValues, ",");
}
- public void updateAdditionalEntries(@NotNull final String values) {
+ public void updateAdditionalEntries(@NotNull final String values, Disposable disposable) {
+ JDOMExternalizableStringList oldValue = myValues;
myValues = reparseProperties(values);
+ if (disposable != null) {
+ Disposer.register(disposable, () -> {
+ myValues = oldValue;
+ });
+ }
}
@NotNull
diff --git a/xml/xml-analysis-impl/src/com/intellij/xml/XmlCustomTagHighlightingPass.kt b/xml/xml-analysis-impl/src/com/intellij/xml/XmlCustomTagHighlightingPass.kt
index 7f3df559ce4c..cf913d89657c 100644
--- a/xml/xml-analysis-impl/src/com/intellij/xml/XmlCustomTagHighlightingPass.kt
+++ b/xml/xml-analysis-impl/src/com/intellij/xml/XmlCustomTagHighlightingPass.kt
@@ -63,9 +63,11 @@ class XmlCustomTagHighlightingPass(val file: PsiFile, editor: Editor) : TextEdit
})
}
- private fun getCustomNames() = (HtmlUtil.getEntitiesString(file, XmlEntitiesInspection.TAG_SHORT_NAME)
- ?.let { StringUtil.split(it, ",").toSet() }
- ?: emptySet())
+ private fun getCustomNames() =
+ HtmlUtil.getEntitiesString(file, XmlEntitiesInspection.TAG_SHORT_NAME)
+ ?.splitToSequence(',')
+ ?.mapTo(HashSet()) { StringUtil.toLowerCase(it) }
+ ?: emptySet()
private fun applyHighlighting(node: ASTNode, elementType: IElementType) {
if (node !is LeafElement) return
@@ -119,7 +121,8 @@ fun isCustomTag(file: PsiFile, tag: XmlTag): Boolean {
return isHtmlLikeFile(file) && !isHtmlTagName(descriptor, tag)
}
-private fun isHtmlLikeFile(file: PsiFile) = file.viewProvider.allFiles.any { it is HtmlCompatibleFile } || HtmlUtil.supportsXmlTypedHandlers(file)
+private fun isHtmlLikeFile(file: PsiFile) = file.viewProvider.allFiles.any { it is HtmlCompatibleFile } || HtmlUtil.supportsXmlTypedHandlers(
+ file)
private fun isHtmlTagName(descriptor: XmlElementDescriptor, tag: XmlTag): Boolean {
if (descriptor is HtmlElementDescriptorImpl) return true