Spellchecker: (minor) refactoring

This commit is contained in:
Olga Strizhenko
2017-11-07 20:16:45 +03:00
parent 572831f8b2
commit b06309b613
@@ -140,7 +140,6 @@ public class SpellCheckerManager implements Disposable {
private void fillEngineDictionary() {
spellChecker.reset();
final List<Loader> loaders = new SmartList<>();
// Load bundled dictionaries from corresponding jars
for (BundledDictionaryProvider provider : Extensions.getExtensions(BundledDictionaryProvider.EP_NAME)) {
for (String dictionary : provider.getBundledDictionaries()) {
@@ -148,7 +147,7 @@ public class SpellCheckerManager implements Disposable {
final Class<? extends BundledDictionaryProvider> loaderClass = provider.getClass();
final InputStream stream = loaderClass.getResourceAsStream(dictionary);
if (stream != null) {
loaders.add(new StreamLoader(stream, dictionary));
spellChecker.loadDictionary(new StreamLoader(stream, dictionary));
}
else {
LOG.warn("Couldn't load dictionary '" + dictionary + "' with loader '" + loaderClass + "'");
@@ -161,16 +160,12 @@ public class SpellCheckerManager implements Disposable {
for (String folder : settings.getDictionaryFoldersPaths()) {
SPFileUtil.processFilesRecursively(folder, s -> {
if (!disabledDictionaries.contains(s)) {
loaders.add(new FileLoader(s));
spellChecker.loadDictionary(new FileLoader(s));
}
});
}
}
for (Loader loader : loaders) {
spellChecker.loadDictionary(loader);
}
final AggregatedDictionaryState dictionaryState = ServiceManager.getService(project, AggregatedDictionaryState.class);
dictionaryState.addDictStateListener((dict) -> restartInspections());
userDictionary = dictionaryState.getDictionary();