mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Spellchecker:(minor) settings renaming
This commit is contained in:
@@ -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<String> 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<String> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
private static final String BUNDLED_DICTIONARY_ATTR_NAME = "BundledDictionary";
|
||||
|
||||
// Paths
|
||||
private List<String> myDictionaryFoldersPaths = new ArrayList<>();
|
||||
private List<String> myCustomDictionariesPaths = new ArrayList<>();
|
||||
private Set<String> myDisabledDictionariesPaths = new HashSet<>();
|
||||
|
||||
private Set<String> myBundledDisabledDictionariesPaths = new HashSet<>();
|
||||
@@ -45,12 +45,12 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
return ServiceManager.getService(project, SpellCheckerSettings.class);
|
||||
}
|
||||
|
||||
public List<String> getDictionaryFoldersPaths() {
|
||||
return myDictionaryFoldersPaths;
|
||||
public List<String> getCustomDictionariesPaths() {
|
||||
return myCustomDictionariesPaths;
|
||||
}
|
||||
|
||||
public void setDictionaryFoldersPaths(List<String> dictionaryFoldersPaths) {
|
||||
myDictionaryFoldersPaths = dictionaryFoldersPaths;
|
||||
public void setCustomDictionariesPaths(List<String> customDictionariesPaths) {
|
||||
myCustomDictionariesPaths = customDictionariesPaths;
|
||||
}
|
||||
|
||||
public Set<String> getDisabledDictionariesPaths() {
|
||||
@@ -75,7 +75,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
@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<Element> {
|
||||
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<Element> {
|
||||
@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<Element> {
|
||||
// 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++) {
|
||||
|
||||
@@ -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<String> disabledDictionaries = new HashSet<>();
|
||||
final HashSet<String> 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)));
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user