use of com.intellij.spellchecker.dictionary.Loader in project intellij-community by JetBrains.
the class BaseSpellChecker method doLoadDictionaryAsync.
private void doLoadDictionaryAsync(Loader loader, Consumer<Dictionary> consumer) {
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> {
LOG.debug("Loading " + loader.getName());
Application app = ApplicationManager.getApplication();
app.executeOnPooledThread(() -> {
if (app.isDisposed())
return;
CompressedDictionary dictionary = CompressedDictionary.create(loader, transform);
LOG.debug(loader.getName() + " loaded!");
consumer.consume(dictionary);
while (!myDictionariesToLoad.isEmpty()) {
if (app.isDisposed())
return;
Pair<Loader, Consumer<Dictionary>> nextDictionary = myDictionariesToLoad.remove(0);
Loader nextDictionaryLoader = nextDictionary.getFirst();
dictionary = CompressedDictionary.create(nextDictionaryLoader, transform);
LOG.debug(nextDictionaryLoader.getName() + " loaded!");
nextDictionary.getSecond().consume(dictionary);
}
LOG.debug("Loading finished, restarting daemon...");
myLoadingDictionaries.set(false);
UIUtil.invokeLaterIfNeeded(() -> {
if (app.isDisposed())
return;
for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
if (project.isInitialized() && project.isOpen() && !project.isDefault()) {
DaemonCodeAnalyzer instance = DaemonCodeAnalyzer.getInstance(project);
if (instance != null)
instance.restart();
}
}
});
});
});
}
use of com.intellij.spellchecker.dictionary.Loader in project intellij-community by JetBrains.
the class SpellCheckerManager method fillEngineDictionary.
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()) {
if (settings == null || !settings.getBundledDisabledDictionariesPaths().contains(dictionary)) {
final Class<? extends BundledDictionaryProvider> loaderClass = provider.getClass();
final InputStream stream = loaderClass.getResourceAsStream(dictionary);
if (stream != null) {
loaders.add(new StreamLoader(stream, dictionary));
} else {
LOG.warn("Couldn't load dictionary '" + dictionary + "' with loader '" + loaderClass + "'");
}
}
}
}
if (settings != null && settings.getDictionaryFoldersPaths() != null) {
final Set<String> disabledDictionaries = settings.getDisabledDictionariesPaths();
for (String folder : settings.getDictionaryFoldersPaths()) {
SPFileUtil.processFilesRecursively(folder, s -> {
if (!disabledDictionaries.contains(s)) {
loaders.add(new FileLoader(s, s));
}
});
}
}
for (Loader loader : loaders) {
spellChecker.loadDictionary(loader);
}
userDictionary = ServiceManager.getService(project, AggregatedDictionaryState.class).getDictionary();
spellChecker.addModifiableDictionary(userDictionary);
}
Aggregations