1. Bug RubyIdentifierSplitter fixed 2. Ruby dic generator significantly improoved 3. Ruby Spell checker strategy corrected for method/module/classes declarations 4. fake Spell checker splitter logic replaced with original, patented Spell Checker algorithm 5. Yep, tests were added! 6. Some API extracted in spell checker plugin - just to break automatic Kate's cherry-pics! 7. And 7-th "tentpole" feature - commit message was added!

This commit is contained in:
Roman Chernyatchik
2010-04-22 21:13:16 +04:00
parent c051e9986c
commit 0b2feff638
@@ -88,7 +88,7 @@ public class SpellCheckingInspection extends LocalInspectionTool {
private static final Map<Language, SpellcheckingStrategy> factories = new HashMap<Language, SpellcheckingStrategy>();
private static void ensureFactoriesAreLoaded() {
public static void ensureFactoriesAreLoaded() {
synchronized (factories) {
if (!factories.isEmpty()) return;
final SpellcheckingStrategy[] spellcheckingStrategies = Extensions.getExtensions(SpellcheckingStrategy.EP_NAME);
@@ -146,11 +146,8 @@ public class SpellCheckingInspection extends LocalInspectionTool {
}
}
final SpellcheckingStrategy factoryByLanguage = getFactoryByLanguage(language);
final Tokenizer tokenizer = factoryByLanguage.getTokenizer(element);
@SuppressWarnings({"unchecked"})
final Token[] tokens = tokenizer.tokenize(element);
final Token[] tokens = tokenize(element, language);
if (tokens == null) return;
Set<String> alreadyChecked = new THashSet<String>();
@@ -161,6 +158,19 @@ public class SpellCheckingInspection extends LocalInspectionTool {
};
}
/**
* Splits element text in tokens according to spell checker strategy of given language
* @param element Psi element
* @param language Usually element.getLanguage()
* @return tokens array
*/
@Nullable
public static Token[] tokenize(@NotNull final PsiElement element, @NotNull final Language language) {
final SpellcheckingStrategy factoryByLanguage = getFactoryByLanguage(language);
final Tokenizer tokenizer = factoryByLanguage.getTokenizer(element);
return tokenizer.tokenize(element);
}
private static void inspect(Token token, ProblemsHolder holder, boolean isOnTheFly,@NotNull Set<String> alreadyChecked, @NotNull SpellCheckerManager manager, NamesValidator... validators) {
List<CheckArea> areaList = token.getAreas();
@@ -253,7 +263,7 @@ public class SpellCheckingInspection extends LocalInspectionTool {
return validators;
}
private static boolean isKeyword(NamesValidator[] validators, PsiElement element, String word) {
public static boolean isKeyword(NamesValidator[] validators, PsiElement element, String word) {
if (validators == null) {
return false;
}