From fb79d018084ae94c95ed2484821542bc2324c970 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Mon, 2 Nov 2009 20:13:30 +0300 Subject: [PATCH] RUBY-5304: Provide rails dictionary for spellchecker --- plugins/spellchecker/src/META-INF/plugin.xml | 1 + .../BundledDictionaryProvider.java | 27 +++++++++++++++++++ .../spellchecker/SpellCheckerManager.java | 12 ++++++--- .../settings/SpellCheckerSettingsPane.java | 2 +- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 plugins/spellchecker/src/com/intellij/spellchecker/BundledDictionaryProvider.java diff --git a/plugins/spellchecker/src/META-INF/plugin.xml b/plugins/spellchecker/src/META-INF/plugin.xml index abbd2798d3fb..0c080c49e107 100644 --- a/plugins/spellchecker/src/META-INF/plugin.xml +++ b/plugins/spellchecker/src/META-INF/plugin.xml @@ -43,6 +43,7 @@ + diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/BundledDictionaryProvider.java b/plugins/spellchecker/src/com/intellij/spellchecker/BundledDictionaryProvider.java new file mode 100644 index 000000000000..236ae4a39c9b --- /dev/null +++ b/plugins/spellchecker/src/com/intellij/spellchecker/BundledDictionaryProvider.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2009 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; + +import com.intellij.openapi.extensions.ExtensionPointName; + +/** + * @author oleg + */ +public interface BundledDictionaryProvider { + ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.spellchecker.bundledDictionaryProvider"); + + String[] getBundledDictionaries(); +} diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java b/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java index 35d9c54368eb..e6e36f6d49bc 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java @@ -19,6 +19,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.spellchecker.dictionary.Dictionary; @@ -47,7 +48,7 @@ public class SpellCheckerManager { private Dictionary userDictionary; - private final String[] bundledDictionaries = new String[]{"english.dic", "jetbrains.dic"}; + private final String[] BUNDLED_DICTIONARIES = new String[]{"english.dic", "jetbrains.dic"}; @NotNull private final SuggestionProvider suggestionProvider = new BaseSuggestionProvider(this); @@ -82,7 +83,7 @@ public class SpellCheckerManager { spellChecker.reset(); final StateLoader stateLoader = new StateLoader(project); final List loaders = new ArrayList(); - for (String dictionary : bundledDictionaries) { + for (String dictionary : getBundledDictionaries()) { if (this.settings == null || !this.settings.getBundledDisabledDictionariesPaths().contains(dictionary)) { loaders.add(new StreamLoader(SpellCheckerManager.class.getResourceAsStream(dictionary))); } @@ -128,7 +129,12 @@ public class SpellCheckerManager { @NotNull public List getBundledDictionaries() { - return (bundledDictionaries != null ? Arrays.asList(bundledDictionaries) : Collections.emptyList()); + final ArrayList dictionaries = new ArrayList(); + dictionaries.addAll(Arrays.asList(BUNDLED_DICTIONARIES)); + for (BundledDictionaryProvider provider : Extensions.getExtensions(BundledDictionaryProvider.EP_NAME)) { + dictionaries.addAll(Arrays.asList(provider.getBundledDictionaries())); + } + return dictionaries; } @NotNull diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index 98488787ab99..a65225166b35 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -209,7 +209,7 @@ public class SpellCheckerSettingsPane implements Disposable { dictionariesFolders.addAll(settings.getDictionaryFoldersPaths()); allDictionaries.clear(); for (String dictionary : manager.getBundledDictionaries()) { - allDictionaries.add(new Pair(dictionary, !settings.getBundledDisabledDictionariesPaths().contains(dictionary))); + allDictionaries.add(Pair.create(dictionary, !settings.getBundledDisabledDictionariesPaths().contains(dictionary))); } // user