RUBY-16568 Spell check does not work outside of HTML tags
authorAndrey Vokin <andrey.vokin@jetbrains.com>
Fri, 10 Apr 2015 16:17:47 +0000 (19:17 +0300)
committerAndrey Vokin <andrey.vokin@jetbrains.com>
Wed, 15 Apr 2015 09:53:10 +0000 (12:53 +0300)
spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java
spellchecker/testData/inspection/xmlWithMistakes/test.html [new file with mode: 0644]
spellchecker/testSrc/com/intellij/spellchecker/inspection/XmlWithMistakesInspectionTest.java

index ccdc1199f5342018584a3c9d1caf08b36f3821f8..fa88295a75cd7fc5d2ea0d66f73e5dd724fb4518 100644 (file)
@@ -25,6 +25,8 @@ import com.intellij.psi.*;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.psi.xml.XmlAttributeValue;
 import com.intellij.psi.xml.XmlText;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.psi.xml.XmlAttributeValue;
 import com.intellij.psi.xml.XmlText;
+import com.intellij.psi.xml.XmlToken;
+import com.intellij.psi.xml.XmlTokenType;
 import com.intellij.spellchecker.inspections.PlainTextSplitter;
 import com.intellij.spellchecker.inspections.TextSplitter;
 import com.intellij.spellchecker.quickfixes.AcceptWordAsCorrect;
 import com.intellij.spellchecker.inspections.PlainTextSplitter;
 import com.intellij.spellchecker.inspections.TextSplitter;
 import com.intellij.spellchecker.quickfixes.AcceptWordAsCorrect;
@@ -71,6 +73,9 @@ public class SpellcheckingStrategy {
       }
       return TEXT_TOKENIZER;
     }
       }
       return TEXT_TOKENIZER;
     }
+    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
+      return TEXT_TOKENIZER;
+    }
     return EMPTY_TOKENIZER;
   }
 
     return EMPTY_TOKENIZER;
   }
 
diff --git a/spellchecker/testData/inspection/xmlWithMistakes/test.html b/spellchecker/testData/inspection/xmlWithMistakes/test.html
new file mode 100644 (file)
index 0000000..4670964
--- /dev/null
@@ -0,0 +1,3 @@
+<a>test</a>
+<TYPO descr="Typo: In word 'ttest'">ttest</TYPO>
+<div>test</div>
\ No newline at end of file
index a212cda9aad278177dcc1d6d3ccb5e4f01378afc..18f039b21533ebd8392534ce7cca8264f20fa0a0 100644 (file)
@@ -27,4 +27,8 @@ public class XmlWithMistakesInspectionTest extends SpellcheckerInspectionTestCas
   public void testXml() {
     doTest("test.xml");
   }
   public void testXml() {
     doTest("test.xml");
   }
+
+  public void testCharacterData() {
+    doTest("test.html");
+  }
 }
 }