diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java index 9615f15995d6..2599714b642d 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java @@ -48,7 +48,7 @@ public class TextSplitter { @NonNls private static final Pattern SPECIAL = Pattern.compile("^&\\p{Alnum}{4};"); - private static final String delimiters = ".,;:!?*/&"; + private static final String delimiters = ".,;:!?*/&\""; private TextSplitter() { @@ -172,7 +172,13 @@ public class TextSplitter { private static void addWord(String text, List results, boolean flag, TextRange found) { boolean tooShort = (found.getEndOffset() - found.getStartOffset()) <= 3; - results.add(new CheckArea(text, found, flag || tooShort)); + for (int i = found.getStartOffset(); idddd) { +def test(int dddd) { } diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/DictionaryTest.java b/plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/DictionaryTest.java index 47120df03721..906030852491 100644 --- a/plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/DictionaryTest.java +++ b/plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/DictionaryTest.java @@ -38,36 +38,30 @@ public class DictionaryTest extends TestCase { private Dictionary dictionary; private Map sizes = new HashMap(); - private Map times = new HashMap(); + private Map times = new HashMap(); + private static final String JETBRAINS_DIC = "jetbrains.dic"; + private static final String ENGLISH_DIC = "english.dic"; { - sizes.put("jetbrains.dic", 1000); - sizes.put("english.dic", 140000); - sizes.put("russian-utf8.dic", 1200000); + sizes.put(JETBRAINS_DIC, 1000); + sizes.put(ENGLISH_DIC, 140000); } - { - times.put("jetbrains.dic", 100); - times.put("english.dic", 2700); - times.put("russian-utf8.dic", 32000); + times.put(JETBRAINS_DIC, 100); + times.put(ENGLISH_DIC, 3500); } public void testDictionary() throws IOException { - - DefaultBundledDictionariesProvider dp = new DefaultBundledDictionariesProvider(); - final String[] names = dp.getBundledDictionaries(); + final String[] names = new String[]{JETBRAINS_DIC,ENGLISH_DIC}; for (String name : names) { - StreamLoader loader = createLoader(name); - loadDictionaryTest(loader, sizes.get(name), name); - loadHalfDictionaryTest(50000, name); + loadDictionaryTest(name, sizes.get(name)); + loadHalfDictionaryTest(name, 50000); } - } - - public void loadDictionaryTest(final Loader loader, int wordCount, final String name) throws IOException { + public void loadDictionaryTest(@NotNull final String name, int wordCount) throws IOException { final Transformation transform = new Transformation(); - + final Loader loader = new StreamLoader(DefaultBundledDictionariesProvider.class.getResourceAsStream(name), name); IdeaTestUtil .assertTiming("Dictionary load depends on words count. Approximate word count: " + wordCount + ".", times.get(name), new Runnable() { public void run() { @@ -76,7 +70,7 @@ public class DictionaryTest extends TestCase { }); final Set wordsToStoreAndCheck = createWordSets(name, 50000, 1).getFirst(); - IdeaTestUtil.assertTiming("Invoke 'contains' " + wordsToStoreAndCheck.size() + " times", 1000, new Runnable() { + IdeaTestUtil.assertTiming("Invoke 'contains' " + wordsToStoreAndCheck.size() + " times", 2000, new Runnable() { public void run() { for (String s : wordsToStoreAndCheck) { assertTrue(dictionary.contains(s)); @@ -86,10 +80,6 @@ public class DictionaryTest extends TestCase { } - private static StreamLoader createLoader(String name) { - return new StreamLoader(DefaultBundledDictionariesProvider.class.getResourceAsStream(name), name); - } - private static Loader createLoader(final Set words) { return new Loader() { public void load(@NotNull Consumer consumer) { @@ -106,7 +96,7 @@ public class DictionaryTest extends TestCase { @SuppressWarnings({"unchecked"}) private static Pair, Set> createWordSets(String name, final int maxCount, final int mod) { - Loader loader = createLoader(name); + Loader loader = new StreamLoader(DefaultBundledDictionariesProvider.class.getResourceAsStream(name), name); final Set wordsToStore = new THashSet(); final Set wordsToCheck = new THashSet(); final Transformation transform = new Transformation(); @@ -135,10 +125,10 @@ public class DictionaryTest extends TestCase { } - public void loadHalfDictionaryTest(final int maxCount, final String name) throws IOException { - + public static void loadHalfDictionaryTest(final String name, final int maxCount) throws IOException { final Pair, Set> sets = createWordSets(name, maxCount, 2); - CompressedDictionary dictionary = CompressedDictionary.create(createLoader(sets.getFirst()), new Transformation()); + final Loader loader = createLoader(sets.getFirst()); + CompressedDictionary dictionary = CompressedDictionary.create(loader, new Transformation()); for (String s : sets.getSecond()) { if (!sets.getFirst().contains(s)) { assertFalse(dictionary.contains(s)); diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index f7e45e32f626..a0313507b136 100644 --- a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -174,7 +174,21 @@ public class SplitterTest extends TestCase { String text = "test   test"; List checkAreas = TextSplitter.splitText(text); correctListToCheck(checkAreas, text, new String[]{"test", "test"}); - correctIgnored(checkAreas, text, new String[]{" "}); + correctIgnored(checkAreas, text, new String[]{}); + } + + public void testColorUC() { + String text = "#AABBFF"; + List checkAreas = TextSplitter.splitText(text); + correctListToCheck(checkAreas, text, new String[]{}); + correctIgnored(checkAreas, text, new String[]{}); + } + + public void testColorLC() { + String text = "#fff"; + List checkAreas = TextSplitter.splitText(text); + correctListToCheck(checkAreas, text, new String[]{}); + correctIgnored(checkAreas, text, new String[]{}); } public void testTooShort() { @@ -270,13 +284,12 @@ public class SplitterTest extends TestCase { correctListToCheck(checkAreas, text, new String[]{}); } - public void testNoWordsInHugeBinaryWithXmlFile() { + public void testTCData() { final InputStream stream = SplitterTest.class.getResourceAsStream("contents.txt"); String text = convertStreamToString(stream); List checkAreas = TextSplitter.splitText(text); List words = wordsToCheck(checkAreas, text); - assertNotNull(words); - assertEquals(45284, words.size()); + assertNull(words); } diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/contents.txt b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/contents.txt index 21733e0fda15..bde7c70d3d06 100644 Binary files a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/contents.txt and b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/contents.txt differ