IDEA-156380 Spellchecker marks `<tbody>` and `<thead>` as typos in .jsp files
authorDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Thu, 11 Aug 2016 09:15:04 +0000 (12:15 +0300)
committerDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Thu, 11 Aug 2016 09:18:27 +0000 (12:18 +0300)
spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java

index 47478266656dd9f49952552473cc3f3a48fdf1ae..96ca42e13c64469c41176b604d0f8cb161948c14 100644 (file)
@@ -2,7 +2,12 @@ package com.intellij.spellchecker.xml;
 
 import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.templateLanguages.TemplateLanguage;
+import com.intellij.psi.xml.XmlToken;
+import com.intellij.psi.xml.XmlTokenType;
 import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy;
+import com.intellij.spellchecker.tokenizer.Tokenizer;
 import com.intellij.util.xml.DomElement;
 import com.intellij.util.xml.DomUtil;
 import org.jetbrains.annotations.NotNull;
@@ -12,6 +17,17 @@ import org.jetbrains.annotations.NotNull;
  */
 public class XmlSpellcheckingStrategy extends SuppressibleSpellcheckingStrategy {
 
+  @NotNull
+  @Override
+  public Tokenizer getTokenizer(PsiElement element) {
+    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
+      PsiFile file = element.getContainingFile();
+      if (file == null || file.getLanguage() instanceof TemplateLanguage)
+        return EMPTY_TOKENIZER;
+    }
+    return super.getTokenizer(element);
+  }
+
   @Override
   public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String name) {
     DomElement domElement = DomUtil.getDomElement(element);