diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/HtmlSpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/HtmlSpellcheckingStrategy.java index 7c7c44c4da52..0fea8e12f7e1 100644 --- a/spellchecker/src/com/intellij/spellchecker/tokenizer/HtmlSpellcheckingStrategy.java +++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/HtmlSpellcheckingStrategy.java @@ -15,11 +15,14 @@ */ package com.intellij.spellchecker.tokenizer; +import com.intellij.codeInsight.completion.HtmlCompletionContributor; import com.intellij.psi.ElementManipulators; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; +import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.io.URLUtil; +import com.intellij.xml.XmlAttributeDescriptor; import org.jetbrains.annotations.NotNull; public class HtmlSpellcheckingStrategy extends SpellcheckingStrategy { @@ -31,6 +34,18 @@ public class HtmlSpellcheckingStrategy extends SpellcheckingStrategy { if (URLUtil.isDataUri(ElementManipulators.getValueText(element))) { return EMPTY_TOKENIZER; } + PsiElement parent = element.getParent(); + if (parent instanceof XmlAttribute) { + if (HtmlCompletionContributor.hasHtmlAttributesCompletion(element) && + HtmlCompletionContributor.addSpecificCompletions((XmlAttribute)parent).length > 0) { + return EMPTY_TOKENIZER; + } + XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor(); + if (descriptor != null && (descriptor.isEnumerated() || descriptor.isFixed())) { + return EMPTY_TOKENIZER; + } + } + return myXmlAttributeTokenizer; } return EMPTY_TOKENIZER; diff --git a/spellchecker/testData/inspection/xmlWithMistakes/attributes.html b/spellchecker/testData/inspection/xmlWithMistakes/attributes.html new file mode 100644 index 000000000000..966922f75e38 --- /dev/null +++ b/spellchecker/testData/inspection/xmlWithMistakes/attributes.html @@ -0,0 +1,5 @@ +
\ No newline at end of file diff --git a/spellchecker/testSrc/com/intellij/spellchecker/inspection/XmlWithMistakesInspectionTest.java b/spellchecker/testSrc/com/intellij/spellchecker/inspection/XmlWithMistakesInspectionTest.java index 18f039b21533..096a18e8e1d4 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/inspection/XmlWithMistakesInspectionTest.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/inspection/XmlWithMistakesInspectionTest.java @@ -31,4 +31,8 @@ public class XmlWithMistakesInspectionTest extends SpellcheckerInspectionTestCas public void testCharacterData() { doTest("test.html"); } + + public void testKnownAttributes() { + doTest("attributes.html"); + } } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/HtmlCompletionContributor.java b/xml/impl/src/com/intellij/codeInsight/completion/HtmlCompletionContributor.java index 043ecefa020a..ece0368ea546 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/HtmlCompletionContributor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/HtmlCompletionContributor.java @@ -46,6 +46,18 @@ import static com.intellij.html.impl.util.MicrodataUtil.*; import static com.intellij.patterns.PlatformPatterns.psiElement; public class HtmlCompletionContributor extends CompletionContributor implements DumbAware { + + public static final String[] TARGET = {"_blank", "_top", "_self", "_parent"}; + public static final String[] ENCTYPE = {"multipart/form-data", "application/x-www-form-urlencoded"}; + public static final String[] REL = {"alternate", "author", "bookmark", "help", "icon", "license", "next", "nofollow", + "noreferrer", "noopener", "prefetch", "prev", "search", "stylesheet", "tag", "start", "contents", "index", + "glossary", "copyright", "chapter", "section", "subsection", "appendix", "script", "import", + "apple-touch-icon", "apple-touch-icon-precomposed", "apple-touch-startup-image"}; + public static final String[] MEDIA = {"all", "braille", "embossed", "handheld", "print", "projection", "screen", "speech", "tty", "tv"}; + public static final String[] LANGUAGE = + {"JavaScript", "VBScript", "JScript", "JavaScript1.2", "JavaScript1.3", "JavaScript1.4", "JavaScript1.5"}; + public static final String[] TYPE = {"text/css", "text/html", "text/plain", "text/xml"}; + public HtmlCompletionContributor() { extend(CompletionType.BASIC, psiElement().inside(XmlPatterns.xmlAttributeValue()), new CompletionProvider