diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java index d81dc80b8e2a..33b787a50f22 100644 --- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java +++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java @@ -37,7 +37,6 @@ import com.intellij.spellchecker.settings.SpellCheckerSettings; import com.intellij.spellchecker.state.AggregatedDictionaryState; import com.intellij.spellchecker.util.SPFileUtil; import com.intellij.spellchecker.util.Strings; -import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -105,9 +104,9 @@ public class SpellCheckerManager implements Disposable { } } } - if (settings != null && settings.getDictionaryFoldersPaths() != null) { + if (settings != null && settings.getCustomDictionariesPaths() != null) { final Set disabledDictionaries = settings.getDisabledDictionariesPaths(); - for (String folder : settings.getDictionaryFoldersPaths()) { + for (String folder : settings.getCustomDictionariesPaths()) { SPFileUtil.processFilesRecursively(folder, s -> { boolean dictionaryShouldBeLoad =!disabledDictionaries.contains(s); boolean dictionaryIsLoad = spellChecker.isDictionaryLoad(s); @@ -155,9 +154,9 @@ public class SpellCheckerManager implements Disposable { } } } - if (settings != null && settings.getDictionaryFoldersPaths() != null) { + if (settings != null && settings.getCustomDictionariesPaths() != null) { final Set disabledDictionaries = settings.getDisabledDictionariesPaths(); - for (String folder : settings.getDictionaryFoldersPaths()) { + for (String folder : settings.getCustomDictionariesPaths()) { SPFileUtil.processFilesRecursively(folder, s -> { if (!disabledDictionaries.contains(s)) { loadDictionary(s); @@ -321,7 +320,7 @@ public class SpellCheckerManager implements Disposable { final String systemDependentPath = toSystemDependentName(path); if (locatedInDictFolders(path)) { spellChecker.removeDictionariesRecursively(systemDependentPath); - mySettings.getDictionaryFoldersPaths().removeIf(dict -> isAncestor(systemDependentPath, dict, false)); + mySettings.getCustomDictionariesPaths().removeIf(dict -> isAncestor(systemDependentPath, dict, false)); mySettings.getDisabledDictionariesPaths().removeIf(dict -> isAncestor(systemDependentPath, dict, false)); restartInspections(); } @@ -350,7 +349,7 @@ public class SpellCheckerManager implements Disposable { } private boolean locatedInDictFolders(@NotNull String path) { - return mySettings.getDictionaryFoldersPaths().stream().anyMatch(dicFolderPath -> isAncestor(dicFolderPath, path, false)); + return mySettings.getCustomDictionariesPaths().stream().anyMatch(dicFolderPath -> isAncestor(dicFolderPath, path, false)); } } } \ No newline at end of file diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java index 87482899cdc2..3e1e1fcb7bfd 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java +++ b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java @@ -36,7 +36,7 @@ public class SpellCheckerSettings implements PersistentStateComponent { private static final String BUNDLED_DICTIONARY_ATTR_NAME = "BundledDictionary"; // Paths - private List myDictionaryFoldersPaths = new ArrayList<>(); + private List myCustomDictionariesPaths = new ArrayList<>(); private Set myDisabledDictionariesPaths = new HashSet<>(); private Set myBundledDisabledDictionariesPaths = new HashSet<>(); @@ -45,12 +45,12 @@ public class SpellCheckerSettings implements PersistentStateComponent { return ServiceManager.getService(project, SpellCheckerSettings.class); } - public List getDictionaryFoldersPaths() { - return myDictionaryFoldersPaths; + public List getCustomDictionariesPaths() { + return myCustomDictionariesPaths; } - public void setDictionaryFoldersPaths(List dictionaryFoldersPaths) { - myDictionaryFoldersPaths = dictionaryFoldersPaths; + public void setCustomDictionariesPaths(List customDictionariesPaths) { + myCustomDictionariesPaths = customDictionariesPaths; } public Set getDisabledDictionariesPaths() { @@ -75,7 +75,7 @@ public class SpellCheckerSettings implements PersistentStateComponent { @SuppressWarnings({"ConstantConditions"}) public Element getState() { if (myBundledDisabledDictionariesPaths.isEmpty() && - myDictionaryFoldersPaths.isEmpty() && + myCustomDictionariesPaths.isEmpty() && myDisabledDictionariesPaths.isEmpty()) { return null; } @@ -90,9 +90,9 @@ public class SpellCheckerSettings implements PersistentStateComponent { i++; } // user - element.setAttribute(FOLDERS_ATTR_NAME, String.valueOf(myDictionaryFoldersPaths.size())); - for (int j = 0; j < myDictionaryFoldersPaths.size(); j++) { - element.setAttribute(FOLDER_ATTR_NAME + j, myDictionaryFoldersPaths.get(j)); + element.setAttribute(FOLDERS_ATTR_NAME, String.valueOf(myCustomDictionariesPaths.size())); + for (int j = 0; j < myCustomDictionariesPaths.size(); j++) { + element.setAttribute(FOLDER_ATTR_NAME + j, myCustomDictionariesPaths.get(j)); } element.setAttribute(DICTIONARIES_ATTR_NAME, String.valueOf(myDisabledDictionariesPaths.size())); iterator = myDisabledDictionariesPaths.iterator(); @@ -109,7 +109,7 @@ public class SpellCheckerSettings implements PersistentStateComponent { @Override public void loadState(@NotNull final Element element) { myBundledDisabledDictionariesPaths.clear(); - myDictionaryFoldersPaths.clear(); + myCustomDictionariesPaths.clear(); myDisabledDictionariesPaths.clear(); try { // bundled @@ -120,7 +120,7 @@ public class SpellCheckerSettings implements PersistentStateComponent { // user final int foldersSize = Integer.valueOf(element.getAttributeValue(FOLDERS_ATTR_NAME)); for (int i = 0; i < foldersSize; i++) { - myDictionaryFoldersPaths.add(element.getAttributeValue(FOLDER_ATTR_NAME + i)); + myCustomDictionariesPaths.add(element.getAttributeValue(FOLDER_ATTR_NAME + i)); } final int scriptsSize = Integer.valueOf(element.getAttributeValue(DICTIONARIES_ATTR_NAME)); for (int i = 0; i < scriptsSize; i++) { diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index d49868b5e294..da97dabc8c39 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -165,7 +165,7 @@ public class SpellCheckerSettingsPane implements Disposable { optionalChooserComponent.apply(); pathsChooserComponent.apply(); - settings.setDictionaryFoldersPaths(new ArrayList<>(pathsChooserComponent.getValues())); + settings.setCustomDictionariesPaths(new ArrayList<>(pathsChooserComponent.getValues())); final HashSet disabledDictionaries = new HashSet<>(); final HashSet bundledDisabledDictionaries = new HashSet<>(); @@ -209,7 +209,7 @@ public class SpellCheckerSettingsPane implements Disposable { private void fillAllDictionaries() { dictionariesFolders.clear(); - dictionariesFolders.addAll(settings.getDictionaryFoldersPaths()); + dictionariesFolders.addAll(settings.getCustomDictionariesPaths()); allDictionaries.clear(); for (String dictionary : SpellCheckerManager.getBundledDictionaries()) { allDictionaries.add(Pair.create(dictionary, !settings.getBundledDisabledDictionariesPaths().contains(dictionary))); diff --git a/spellchecker/testSrc/com/intellij/spellchecker/dictionary/CustomDictionaryTest.java b/spellchecker/testSrc/com/intellij/spellchecker/dictionary/CustomDictionaryTest.java index 0408697f045a..d6a184720901 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/dictionary/CustomDictionaryTest.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/dictionary/CustomDictionaryTest.java @@ -28,7 +28,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import static com.intellij.openapi.util.io.FileUtil.createTempDirectory; @@ -52,8 +51,8 @@ public class CustomDictionaryTest extends SpellcheckerInspectionTestCase { super.setUp(); settings = SpellCheckerSettings.getInstance(getProject()); spellCheckerManager = SpellCheckerManager.getInstance(getProject()); - oldPaths = settings.getDictionaryFoldersPaths(); - settings.setDictionaryFoldersPaths(new ArrayList<>(singletonList(getTestDictDirectory()))); + oldPaths = settings.getCustomDictionariesPaths(); + settings.setCustomDictionariesPaths(new ArrayList<>(singletonList(getTestDictDirectory()))); spellCheckerManager.fullConfigurationReload(); } @@ -61,7 +60,7 @@ public class CustomDictionaryTest extends SpellcheckerInspectionTestCase { protected void tearDown() throws Exception { //noinspection SuperTearDownInFinally super.tearDown(); - settings.setDictionaryFoldersPaths(oldPaths); + settings.setCustomDictionariesPaths(oldPaths); } @Override