From fe5f20c043c8e964620dc367d12efac3541c366f Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Tue, 15 Nov 2011 15:32:48 +0400 Subject: [PATCH] IDEA-76562 Suppressing spell checking for eastern Asian languages looks incomplete --- .../inspections/IdentifierSplitter.java | 17 +++++++++++++- .../inspections/PlainTextSplitter.java | 22 +++++++++---------- .../testData/inspection/java/Japaneese.java | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java index 8c8f124659e8..66c65d958102 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java @@ -84,7 +84,7 @@ public class IdentifierSplitter extends BaseSplitter { } @NotNull - public static List splitByCase(@NotNull String text, @NotNull TextRange range) { + private static List splitByCase(@NotNull String text, @NotNull TextRange range) { //System.out.println("text = " + text + " range = " + range); List result = new ArrayList(); int i = range.getStartOffset(); @@ -92,6 +92,21 @@ public class IdentifierSplitter extends BaseSplitter { int prevType = Character.MATH_SYMBOL; while (i < range.getEndOffset()) { final char ch = text.charAt(i); + if (ch >= '\u3040' && ch <= '\u309f' || // Hiragana + ch >= '\u30A0' && ch <= '\u30ff' || // Katakana + ch >= '\u4E00' && ch <= '\u9FFF' || // CJK Unified ideographs + ch >= '\uF900' && ch <= '\uFAFF' || // CJK Compatibility Ideographs + ch >= '\uFF00' && ch <= '\uFFEF' //Halfwidth and Fullwidth Forms of Katakana & Fullwidth ASCII variants + ) { + if (s >= 0) { + add(text, result, i, s); + s = -1; + } + prevType = Character.MATH_SYMBOL; + ++i; + continue; + } + final int type = Character.getType(ch); if (type == Character.LOWERCASE_LETTER || type == Character.UPPERCASE_LETTER || diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java index 579536abd1b1..0ec175a083bd 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java @@ -52,17 +52,17 @@ public class PlainTextSplitter extends BaseSplitter { if (Verifier.checkCharacterData(substring) != null) { return; } - for(int i = 0; i < text.length(); ++i) { - final char ch = text.charAt(i); - if (ch >= '\u3040' && ch <= '\u309f' || // Hiragana - ch >= '\u30A0' && ch <= '\u30ff' || // Katakana - ch >= '\u4E00' && ch <= '\u9FFF' || // CJK Unified ideographs - ch >= '\uF900' && ch <= '\uFAFF' || // CJK Compatibility Ideographs - ch >= '\uFF00' && ch <= '\uFFEF' //Halfwidth and Fullwidth Forms of Katakana & Fullwidth ASCII variants - ) { - return; - } - } + //for(int i = 0; i < text.length(); ++i) { + // final char ch = text.charAt(i); + // if (ch >= '\u3040' && ch <= '\u309f' || // Hiragana + // ch >= '\u30A0' && ch <= '\u30ff' || // Katakana + // ch >= '\u4E00' && ch <= '\u9FFF' || // CJK Unified ideographs + // ch >= '\uF900' && ch <= '\uFAFF' || // CJK Compatibility Ideographs + // ch >= '\uFF00' && ch <= '\uFFEF' //Halfwidth and Fullwidth Forms of Katakana & Fullwidth ASCII variants + // ) { + // return; + // } + //} List toCheck; if (text.indexOf('@')>0) { diff --git a/plugins/spellchecker/testData/inspection/java/Japaneese.java b/plugins/spellchecker/testData/inspection/java/Japaneese.java index 617fc02f086d..3eae1726a235 100644 --- a/plugins/spellchecker/testData/inspection/java/Japaneese.java +++ b/plugins/spellchecker/testData/inspection/java/Japaneese.java @@ -16,7 +16,7 @@ /** CJK Compatibility Ideographs (F900 - FAFF) * 﨎鶴﨎鶴﨎鶴 */ - +/* 私はJabaが好きです。私はJabaが好きです。*/ /** * プロセス毎に使われるコールスタックは一つだけ !!! */