no need ensureFactoriesAreLoaded() / retrieving names validators each time
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Fri, 26 Feb 2010 08:38:17 +0000 (11:38 +0300)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Fri, 26 Feb 2010 08:38:17 +0000 (11:38 +0300)
plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java

index 3aa278bd53d7ed7e6c4cd347f857b6f067f0c7e8..359f1f9783a80f2324421a13c2d44f16438fcf54 100644 (file)
@@ -106,7 +106,10 @@ public class SpellCheckingInspection extends LocalInspectionTool {
   @NotNull
   public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
     return new PsiElementVisitor() {
-
+      private final NamesValidator[] NAMES_VALIDATORS = getNamesValidators();
+      {
+        ensureFactoriesAreLoaded();
+      }
       @Override
       public void visitElement(final PsiElement element) {
 
@@ -136,8 +139,6 @@ public class SpellCheckingInspection extends LocalInspectionTool {
           }
         }
 
-        ensureFactoriesAreLoaded();
-
         final SpellcheckingStrategy factoryByLanguage = getFactoryByLanguage(language);
         final Tokenizer tokenizer = factoryByLanguage.getTokenizer(element);
         @SuppressWarnings({"unchecked"})
@@ -146,7 +147,7 @@ public class SpellCheckingInspection extends LocalInspectionTool {
           return;
         }
         for (Token token : tokens) {
-          inspect(token, holder, isOnTheFly, getNamesValidators());
+          inspect(token, holder, isOnTheFly, NAMES_VALIDATORS);
         }
       }
     };