diff --git a/plugins/java-i18n/src/com/intellij/spellchecker/DocCommentTokenizer.java b/plugins/java-i18n/src/com/intellij/spellchecker/DocCommentTokenizer.java index 3cbcc34ed38f..c62276b44e6a 100644 --- a/plugins/java-i18n/src/com/intellij/spellchecker/DocCommentTokenizer.java +++ b/plugins/java-i18n/src/com/intellij/spellchecker/DocCommentTokenizer.java @@ -20,7 +20,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.javadoc.PsiDocTag; import com.intellij.spellchecker.inspections.CommentSplitter; -import com.intellij.spellchecker.inspections.SplitterFactory; import com.intellij.spellchecker.tokenizer.TokenConsumer; import com.intellij.spellchecker.tokenizer.Tokenizer; import org.jetbrains.annotations.NotNull; @@ -37,7 +36,7 @@ public class DocCommentTokenizer extends Tokenizer { @Override public void tokenize(@NotNull PsiDocComment comment, TokenConsumer consumer) { - final CommentSplitter splitter = SplitterFactory.getInstance().getCommentSplitter(); + final CommentSplitter splitter = CommentSplitter.getInstance(); for (PsiElement el : comment.getChildren()) { if (el instanceof PsiDocTag) { diff --git a/plugins/java-i18n/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java b/plugins/java-i18n/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java index 0627a0a3f7b0..3302bca5a96f 100644 --- a/plugins/java-i18n/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java +++ b/plugins/java-i18n/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java @@ -20,7 +20,7 @@ import com.intellij.psi.PsiClassType; import com.intellij.psi.PsiLiteralExpression; import com.intellij.psi.PsiModifierListOwner; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.PlainTextSplitter; import com.intellij.spellchecker.tokenizer.TokenConsumer; import com.intellij.spellchecker.tokenizer.Tokenizer; import org.jetbrains.annotations.NotNull; @@ -44,6 +44,6 @@ public class LiteralExpressionTokenizer extends Tokenizer return; } - consumer.consumeToken(element, SplitterFactory.getInstance().getStringLiteralSplitter()); + consumer.consumeToken(element, PlainTextSplitter.getInstance()); } } diff --git a/plugins/java-i18n/src/com/intellij/spellchecker/NamedElementTokenizer.java b/plugins/java-i18n/src/com/intellij/spellchecker/NamedElementTokenizer.java index 2fb7459b2474..2e6588156143 100644 --- a/plugins/java-i18n/src/com/intellij/spellchecker/NamedElementTokenizer.java +++ b/plugins/java-i18n/src/com/intellij/spellchecker/NamedElementTokenizer.java @@ -19,7 +19,7 @@ import com.intellij.psi.PsiIdentifier; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.PsiTypeElement; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.IdentifierSplitter; import com.intellij.spellchecker.tokenizer.TokenConsumer; import com.intellij.spellchecker.tokenizer.Tokenizer; import com.intellij.spellchecker.tokenizer.TokenizerBase; @@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull; * @author shkate@jetbrains.com */ public class NamedElementTokenizer extends Tokenizer { - private final Tokenizer myIdentifierTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getIdentifierSplitter()); + private final Tokenizer myIdentifierTokenizer = TokenizerBase.create(IdentifierSplitter.getInstance()); private final PsiTypeTokenizer myTypeTokenizer = new PsiTypeTokenizer(); @Override diff --git a/plugins/java-i18n/src/com/intellij/spellchecker/PsiTypeTokenizer.java b/plugins/java-i18n/src/com/intellij/spellchecker/PsiTypeTokenizer.java index 64fb1d995cf3..6406c79b3f24 100644 --- a/plugins/java-i18n/src/com/intellij/spellchecker/PsiTypeTokenizer.java +++ b/plugins/java-i18n/src/com/intellij/spellchecker/PsiTypeTokenizer.java @@ -25,7 +25,7 @@ import com.intellij.psi.PsiType; import com.intellij.psi.PsiTypeElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.IdentifierSplitter; import com.intellij.spellchecker.tokenizer.TokenConsumer; import com.intellij.spellchecker.tokenizer.Tokenizer; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public class PsiTypeTokenizer extends Tokenizer { final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile); if (isInSource) { consumer.consumeToken(element, element.getText(), true, 0, getRangeToCheck(element.getText(), psiClass.getName()), - SplitterFactory.getInstance().getIdentifierSplitter()); + IdentifierSplitter.getInstance()); } } diff --git a/plugins/properties/src/com/intellij/lang/properties/spellchecker/PropertiesSpellcheckingStrategy.java b/plugins/properties/src/com/intellij/lang/properties/spellchecker/PropertiesSpellcheckingStrategy.java index c1d4b14b1378..6b06ebbee0ea 100644 --- a/plugins/properties/src/com/intellij/lang/properties/spellchecker/PropertiesSpellcheckingStrategy.java +++ b/plugins/properties/src/com/intellij/lang/properties/spellchecker/PropertiesSpellcheckingStrategy.java @@ -19,7 +19,8 @@ import com.intellij.lang.properties.psi.impl.PropertyImpl; import com.intellij.lang.properties.psi.impl.PropertyValueImpl; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.PlainTextSplitter; +import com.intellij.spellchecker.inspections.PropertiesSplitter; import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy; import com.intellij.spellchecker.tokenizer.TokenConsumer; import com.intellij.spellchecker.tokenizer.Tokenizer; @@ -28,7 +29,7 @@ import org.jetbrains.annotations.NotNull; public class PropertiesSpellcheckingStrategy extends SpellcheckingStrategy { - private Tokenizer myPropertyValueTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getStringLiteralSplitter()); + private Tokenizer myPropertyValueTokenizer = TokenizerBase.create(PlainTextSplitter.getInstance()); private Tokenizer myPropertyTokenizer = new MyPropertyTokenizer(); @NotNull @@ -46,7 +47,7 @@ public class PropertiesSpellcheckingStrategy extends SpellcheckingStrategy { private static class MyPropertyTokenizer extends Tokenizer { public void tokenize(@NotNull PropertyImpl element, TokenConsumer consumer) { String key = element.getKey(); - consumer.consumeToken(element, key, true, 0, TextRange.allOf(key), SplitterFactory.getInstance().getPropertiesSplitter()); + consumer.consumeToken(element, key, true, 0, TextRange.allOf(key), PropertiesSplitter.getInstance()); } } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/CommentSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/CommentSplitter.java index bebc67f2b919..4d1124843c57 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/CommentSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/CommentSplitter.java @@ -26,6 +26,12 @@ import java.util.regex.Pattern; public class CommentSplitter extends BaseSplitter { private static final Pattern HTML = Pattern.compile("<(\\S+?).*?>(.*?)"); + + private static final CommentSplitter INSTANCE = new CommentSplitter(); + + public static CommentSplitter getInstance() { + return INSTANCE; + } @Override public void split(@Nullable String text, @NotNull TextRange range, Consumer consumer) { @@ -34,7 +40,7 @@ public class CommentSplitter extends BaseSplitter { } List toCheck = excludeByPattern(text, range, HTML, 2); - final Splitter ps = SplitterFactory.getInstance().getPlainTextSplitter(); + final Splitter ps = PlainTextSplitter.getInstance(); for (TextRange r : toCheck) { ps.split(text, r, consumer); } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java index 41f5cac437bd..8c8f124659e8 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java @@ -29,6 +29,11 @@ import java.util.regex.Pattern; public class IdentifierSplitter extends BaseSplitter { + private static final IdentifierSplitter INSTANCE = new IdentifierSplitter(); + + public static IdentifierSplitter getInstance() { + return INSTANCE; + } @NonNls private static final Pattern WORD = Pattern.compile("\\b\\p{L}*'?\\p{L}*"); diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java index e765f98d8cf0..fe8ce702dfe0 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java @@ -28,7 +28,11 @@ import java.util.List; import java.util.regex.Pattern; public class PlainTextSplitter extends BaseSplitter { + private static final PlainTextSplitter INSTANCE = new PlainTextSplitter(); + public static PlainTextSplitter getInstance() { + return INSTANCE; + } @NonNls private static final Pattern MAIL = @@ -61,7 +65,7 @@ public class PlainTextSplitter extends BaseSplitter { toCheck = Collections.singletonList(range); } - final TextSplitter ws = SplitterFactory.getInstance().getTextSplitterNew(); + final TextSplitter ws = TextSplitter.getInstance(); for (TextRange r : toCheck) { checkCancelled(); diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PropertiesSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PropertiesSplitter.java index 4dd7488b60f8..77e6117774cc 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PropertiesSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/PropertiesSplitter.java @@ -26,18 +26,21 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class PropertiesSplitter extends BaseSplitter { - + private static final PropertiesSplitter INSTANCE = new PropertiesSplitter(); + + public static PropertiesSplitter getInstance() { + return INSTANCE; + } @NonNls private static final Pattern WORD = Pattern.compile("\\p{L}*"); - @Override public void split(@Nullable String text, @NotNull TextRange range, Consumer consumer) { if (text == null || StringUtil.isEmpty(text)) { return; } - final IdentifierSplitter splitter = SplitterFactory.getInstance().getIdentifierSplitter(); + final IdentifierSplitter splitter = IdentifierSplitter.getInstance(); Matcher matcher = WORD.matcher(range.substring(text)); while (matcher.find()) { if (matcher.end() - matcher.start() < MIN_RANGE_LENGTH) { diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SplitterFactory.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SplitterFactory.java deleted file mode 100644 index 0589db116c6b..000000000000 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SplitterFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.spellchecker.inspections; - -public class SplitterFactory { - - private static final SplitterFactory ourInstance = new SplitterFactory(); - - private final IdentifierSplitter identifierSplitter = new IdentifierSplitter(); - private final PlainTextSplitter plainTextSpl = new PlainTextSplitter(); - private final PropertiesSplitter prSpl = new PropertiesSplitter(); - private final WordSplitter wordSplitter = new WordSplitter(); - private final CommentSplitter comment = new CommentSplitter(); - private final TextSplitter textSpl = new TextSplitter(); - - - private SplitterFactory() { - } - - public static SplitterFactory getInstance() { - return ourInstance; - } - - public IdentifierSplitter getIdentifierSplitter() { - return identifierSplitter; - } - - public WordSplitter getWordSplitter() { - return wordSplitter; - } - - public BaseSplitter getAttributeValueSplitter() { - return textSpl; - } - - public BaseSplitter getPlainTextSplitter() { - return plainTextSpl; - } - - public CommentSplitter getCommentSplitter() { - return comment; - } - - public BaseSplitter getStringLiteralSplitter() { - return plainTextSpl; - } - - public BaseSplitter getPropertiesSplitter() { - return prSpl; - } - - public TextSplitter getTextSplitterNew() { - return textSpl; - } -} diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java index b89a6baee25c..ea7c75820e70 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java @@ -25,6 +25,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class TextSplitter extends BaseSplitter { + private static final TextSplitter INSTANCE = new TextSplitter(); + + public static TextSplitter getInstance() { + return INSTANCE; + } private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile("([&#]|0x[0-9]*)?\\p{L}+'?\\p{L}(_*\\p{L})*"); @@ -37,7 +42,7 @@ public class TextSplitter extends BaseSplitter { } protected void doSplit(@NotNull String text, @NotNull TextRange range, Consumer consumer) { - final WordSplitter ws = SplitterFactory.getInstance().getWordSplitter(); + final WordSplitter ws = WordSplitter.getInstance(); Matcher matcher = EXTENDED_WORD_AND_SPECIAL.matcher(range.substring(text)); while (matcher.find()) { TextRange found = matcherRange(range, matcher); diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java index 6366f4f1f1a6..fd6204af460f 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java @@ -25,6 +25,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class WordSplitter extends BaseSplitter { + private static final WordSplitter INSTANCE = new WordSplitter(); + + public static WordSplitter getInstance() { + return INSTANCE; + } @NonNls private static final Pattern SPECIAL = Pattern.compile("&\\p{Alnum}{4};?|#\\p{Alnum}{3,6}|0x\\p{Alnum}?"); @@ -41,7 +46,7 @@ public class WordSplitter extends BaseSplitter { addWord(consumer, true, found); } else { - SplitterFactory.getInstance().getIdentifierSplitter().split(text, range, consumer); + IdentifierSplitter.getInstance().split(text, range, consumer); } } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/CommentTokenizer.java b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/CommentTokenizer.java index e1c70e10dc3f..2f1610022ea5 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/CommentTokenizer.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/CommentTokenizer.java @@ -16,7 +16,7 @@ package com.intellij.spellchecker.tokenizer; import com.intellij.psi.PsiComment; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.CommentSplitter; import org.jetbrains.annotations.NotNull; public class CommentTokenizer extends Tokenizer { @@ -25,6 +25,6 @@ public class CommentTokenizer extends Tokenizer { public void tokenize(@NotNull PsiComment element, TokenConsumer consumer) { // doccomment chameleon expands as PsiComment inside PsiComment, avoid duplication if (element.getParent() instanceof PsiComment) return; - consumer.consumeToken(element, SplitterFactory.getInstance().getCommentSplitter()); + consumer.consumeToken(element, CommentSplitter.getInstance()); } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/PsiIdentifierOwnerTokenizer.java b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/PsiIdentifierOwnerTokenizer.java index 4eb362b2027c..46911e966b87 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/PsiIdentifierOwnerTokenizer.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/PsiIdentifierOwnerTokenizer.java @@ -19,7 +19,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNameIdentifierOwner; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.IdentifierSplitter; import org.jetbrains.annotations.NotNull; @@ -40,6 +40,6 @@ public class PsiIdentifierOwnerTokenizer extends Tokenizer myCommentTokenizer = new CommentTokenizer(); - protected final Tokenizer myXmlAttributeTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getAttributeValueSplitter()); + protected final Tokenizer myXmlAttributeTokenizer = TokenizerBase.create(TextSplitter.getInstance()); protected final Tokenizer myXmlTextTokenizer = new XmlTextTokenizer(); public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.spellchecker.support"); @@ -39,7 +40,7 @@ public class SpellcheckingStrategy { } }; - public static final Tokenizer TEXT_TOKENIZER = new TokenizerBase(SplitterFactory.getInstance().getPlainTextSplitter()); + public static final Tokenizer TEXT_TOKENIZER = new TokenizerBase(PlainTextSplitter.getInstance()); @NotNull public Tokenizer getTokenizer(PsiElement element) { diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlTextTokenizer.java b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlTextTokenizer.java index 266662161dde..426aeb369a2b 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlTextTokenizer.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlTextTokenizer.java @@ -20,7 +20,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.xml.XmlText; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.PlainTextSplitter; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -31,6 +31,6 @@ public class XmlTextTokenizer extends Tokenizer { if(element.getContainingFile().getContext() != null) return; // outer element should care of spell checking List> list = InjectedLanguageUtil.getInjectedPsiFiles(element); if (list != null && list.size() > 0) return; - consumer.consumeToken(element, SplitterFactory.getInstance().getPlainTextSplitter()); + consumer.consumeToken(element, PlainTextSplitter.getInstance()); } } diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index fc79a89aad62..6647c2421dbf 100644 --- a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -16,8 +16,7 @@ package com.intellij.spellchecker.inspector; import com.intellij.openapi.util.TextRange; -import com.intellij.spellchecker.inspections.Splitter; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.*; import com.intellij.util.Consumer; import junit.framework.Assert; import junit.framework.TestCase; @@ -37,318 +36,318 @@ public class SplitterTest extends TestCase { public void testSplitSimpleCamelCase() { String text = "simpleCamelCase"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "simple", "Camel", "Case"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "simple", "Camel", "Case"); } public void testSplitCamelCaseWithUpperCasedWord() { String text = "camelCaseJSP"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "camel", "Case"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "camel", "Case"); } public void testArrays() { String text = "Token[]"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "Token"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "Token"); } public void testIdentifierInSingleQuotes() { String text = "'fill'"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "fill"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "fill"); } public void testWordsInSingleQuotesWithSep() { String text = "'test-something'"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "test", "something"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "test", "something"); } public void testComplexWordsInQuotes() { String text = "\"test-customer's'\""; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "test", "customer's"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "test", "customer's"); } public void testCapitalizedWithShortWords() { String text = "IntelliJ"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "Intelli"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "Intelli"); } public void testWords() { String text = "first-last"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "first", "last"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "first", "last"); } public void testCapitalizedWithShortAndLongWords() { String text = "IntelliJTestTest"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "Intelli", "Test", "Test"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "Intelli", "Test", "Test"); } public void testWordWithApostrophe1() { String text = "don't check"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "don't", "check"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "don't", "check"); } public void testHexInPlainText() { String text = "some text 0xacvfgt"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "some", "text"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "some", "text"); } public void testHexInStringLiteral() { String text = "qwerty 0x12acfgt test"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "qwerty", "test"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "qwerty", "test"); } public void testHex() { String text = "0xacvfgt"; - correctListToCheck(SplitterFactory.getInstance().getWordSplitter(), text); + correctListToCheck(WordSplitter.getInstance(), text); } public void testCheckXmlIgnored() { String text = "abcdef" + new String(new char[]{0xDC00}) + "test"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text); + correctListToCheck(PlainTextSplitter.getInstance(), text); } public void testIdentifiersWithNumbers() { String text = "result1"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "result"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "result"); } public void testIdentifiersWithNumbersInside() { String text = "result1result"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "result","result"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "result","result"); } public void testWordWithApostrophe2() { String text = "customers'"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "customers"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "customers"); } public void testWordWithApostrophe3() { String text = "customer's"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "customer's"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "customer's"); } public void testWordWithApostrophe4() { String text = "we'll"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "we'll"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "we'll"); } public void testWordWithApostrophe5() { String text = "I'm you're we'll"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "you're", "we'll"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "you're", "we'll"); } public void testConstantName() { String text = "TEST_CONSTANT"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "TEST", "CONSTANT"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "TEST", "CONSTANT"); } public void testLongConstantName() { String text = "TEST_VERY_VERY_LONG_AND_COMPLEX_CONSTANT"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "TEST", "VERY", "VERY", "LONG", "COMPLEX", "CONSTANT"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "TEST", "VERY", "VERY", "LONG", "COMPLEX", "CONSTANT"); } public void testJavaComments() { String text = "/*special symbols*/"; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "special", "symbols"); + correctListToCheck(CommentSplitter.getInstance(), text, "special", "symbols"); } public void testXmlComments() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "special", "symbols"); + correctListToCheck(CommentSplitter.getInstance(), text, "special", "symbols"); } public void testCamelCaseInXmlComments() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "special", "Case", "symbols"); + correctListToCheck(CommentSplitter.getInstance(), text, "special", "Case", "symbols"); } public void testWordsWithNumbers() { String text = "testCamelCase123"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "test", "Camel", "Case"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "test", "Camel", "Case"); } public void testCommentsWithWordsWithNumbers() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "special", "Case", "symbols"); + correctListToCheck(CommentSplitter.getInstance(), text, "special", "Case", "symbols"); } public void testCommentsWithAbr() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "Test", "Class"); + correctListToCheck(CommentSplitter.getInstance(), text, "Test", "Class"); } public void testStringLiterals() { String text = "test\ntest\n"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "test", "test"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "test", "test"); } public void testCommentWithHtml() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "something", "here", "next", "content", "foooo", "barrrr", + correctListToCheck(CommentSplitter.getInstance(), text, "something", "here", "next", "content", "foooo", "barrrr", "text"); } public void testCommentWithHtmlTagsAndAtr() { String text = ""; - correctListToCheck(SplitterFactory.getInstance().getCommentSplitter(), text, "something", "here", "foooo", "barrrr", "text", "text"); + correctListToCheck(CommentSplitter.getInstance(), text, "something", "here", "foooo", "barrrr", "text", "text"); } public void testSpecial() { String text = "test   test"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "test", "test"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "test", "test"); } public void testColorUC() { String text = "#AABBFF"; - correctListToCheck(SplitterFactory.getInstance().getWordSplitter(), text); + correctListToCheck(WordSplitter.getInstance(), text); } public void testColorUCSC() { String text = "#AABBFF;"; - correctListToCheck(SplitterFactory.getInstance().getWordSplitter(), text); + correctListToCheck(WordSplitter.getInstance(), text); } public void testColorUCSurrounded() { String text = "\"#AABBFF\""; - correctListToCheck(SplitterFactory.getInstance().getWordSplitter(), text); + correctListToCheck(WordSplitter.getInstance(), text); } public void testColorLC() { String text = "#fff"; - correctListToCheck(SplitterFactory.getInstance().getAttributeValueSplitter(), text); + correctListToCheck(TextSplitter.getInstance(), text); } public void testTooShort() { String text = "bgColor carLight"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "Color", "Light"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "Color", "Light"); } public void testPhpVariableCorrectSimple() { String text = "$this"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "this"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "this"); } public void testPhpVariableCorrect() { String text = "$this_this$this"; - correctListToCheck(SplitterFactory.getInstance().getIdentifierSplitter(), text, "this", "this", "this"); + correctListToCheck(IdentifierSplitter.getInstance(), text, "this", "this", "this"); } public void testEmail() { String text = "some text with email (shkate.test@gmail.com) inside"; - correctListToCheck(SplitterFactory.getInstance().getStringLiteralSplitter(), text, "some", "text", "with", "email", "inside"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "some", "text", "with", "email", "inside"); } public void testEmailOnly() { String text = "shkate123-\u00DC.test@gmail.com"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text); + correctListToCheck(PlainTextSplitter.getInstance(), text); } public void testUrl() { String text = "http://www.jetbrains.com/idea"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text); + correctListToCheck(PlainTextSplitter.getInstance(), text); } public void testWordBeforeDelimiter() { String text = "badd,"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "badd"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "badd"); } public void testWordAfterDelimiter() { String text = ",badd"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "badd"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "badd"); } public void testWordInCapsBeforeDelimiter() { String text = "BADD,"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "BADD"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "BADD"); } public void testWordInCapsAfterDelimiter() { String text = ",BADD"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "BADD"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "BADD"); } public void testWordInCapsAfterDelimiter2() { String text = "BADD;"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "BADD"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "BADD"); } public void testWordInCapsAfterDelimiter3() { String text = ";BADD;"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "BADD"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "BADD"); } public void testWordWithUmlauts() { String text = "rechtsb\u00FCndig"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, text); + correctListToCheck(PlainTextSplitter.getInstance(), text, text); } public void testWordUpperCasedWithUmlauts() { String text = "RECHTSB\u00DCNDIG"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, text); + correctListToCheck(PlainTextSplitter.getInstance(), text, text); } public void testCommaSeparatedList() { String text = "properties,test,properties"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "properties", "test", "properties"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "properties", "test", "properties"); } public void testSemicolonSeparatedList() { String text = "properties;test;properties"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, "properties", "test", "properties"); + correctListToCheck(PlainTextSplitter.getInstance(), text, "properties", "test", "properties"); } public void testProperties1() { String text = "properties.test.properties"; - correctListToCheck(SplitterFactory.getInstance().getPropertiesSplitter(), text, "properties", "test", "properties"); + correctListToCheck(PropertiesSplitter.getInstance(), text, "properties", "test", "properties"); } public void testPropertiesWithCamelCase() { String text = "upgrade.testCommit.propertiesSomeNews"; - correctListToCheck(SplitterFactory.getInstance().getPropertiesSplitter(), text, "upgrade", "test", "Commit", "properties", "Some", + correctListToCheck(PropertiesSplitter.getInstance(), text, "upgrade", "test", "Commit", "properties", "Some", "News"); } public void testWordUpperCasedWithUmlautsInTheBeginning() { String text = "\u00DCNDIG"; - correctListToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text, text); + correctListToCheck(PlainTextSplitter.getInstance(), text, text); } public void testTCData() { final InputStream stream = SplitterTest.class.getResourceAsStream("contents.txt"); String text = convertStreamToString(stream); - List words = wordsToCheck(SplitterFactory.getInstance().getPlainTextSplitter(), text); + List words = wordsToCheck(PlainTextSplitter.getInstance(), text); assertEquals(0, words.size()); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java index f7d0607891ae..011634a59876 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java @@ -18,7 +18,7 @@ package com.intellij.uiDesigner.inspections; import com.intellij.openapi.module.Module; import com.intellij.openapi.util.TextRange; import com.intellij.spellchecker.SpellCheckerManager; -import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.spellchecker.inspections.PlainTextSplitter; import com.intellij.uiDesigner.lw.IComponent; import com.intellij.uiDesigner.lw.IProperty; import com.intellij.uiDesigner.lw.StringDescriptor; @@ -45,7 +45,7 @@ public class FormSpellCheckingInspection extends StringDescriptorInspection { return; } final SpellCheckerManager manager = SpellCheckerManager.getInstance(module.getProject()); - SplitterFactory.getInstance().getPlainTextSplitter().split(value, TextRange.allOf(value), new Consumer() { + PlainTextSplitter.getInstance().split(value, TextRange.allOf(value), new Consumer() { @Override public void consume(TextRange textRange) { String word = textRange.substring(value);