From 3ff95b8d54aa80004be52cc5fe3caca2c92cc052 Mon Sep 17 00:00:00 2001 From: Ekaterina Shliakhovetskaja Date: Wed, 28 Oct 2009 13:23:37 +0300 Subject: [PATCH] Spellchecker: fix state serialization - do not save default settings --- .../settings/SpellCheckerSettings.java | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java index 8ad57b734b1c..783fa17406df 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettings.java @@ -15,7 +15,10 @@ */ package com.intellij.spellchecker.settings; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -63,43 +66,10 @@ public class SpellCheckerSettings implements PersistentStateComponent { } - public Set getEnabledDictionariesPaths() { - final HashSet enabledDictionaries = new HashSet(); - for (String folder : myDictionaryFoldersPaths) { - /*RFileUtil.processFilesRecursively(folder, new Consumer() { - public void consume(final String s) { - if (!myDisabledDictionariesPaths.contains(s)){ - enabledDictionaries.add(s); - } - } - });*/ - } - return enabledDictionaries; - } - - public Set getBundledEnabledDictionariesPaths() { - final HashSet bundledEnabledDictionaries = new HashSet(); - final List builtInFolders = getBundledDictionariesFoldersPaths(); - for (String folder : builtInFolders) { - /*RFileUtil.processFilesRecursively(folder, new Consumer() { - public void consume(final String s) { - if (!myBundledDisabledDictionariesPaths.contains(s)){ - bundledEnabledDictionaries.add(s); - } - } - });*/ - } - return bundledEnabledDictionaries; - } - public void setDisabledDictionariesPaths(Set disabledDictionariesPaths) { myDisabledDictionariesPaths = disabledDictionariesPaths; } - public List getBundledDictionariesFoldersPaths() { - /*return Collections.unmodifiableList(RubySupportLoader.getBuiltinScriptFolders());*/ - return Collections.emptyList(); - } public Set getBundledDisabledDictionariesPaths() { return myBundledDisabledDictionariesPaths; @@ -109,7 +79,14 @@ public class SpellCheckerSettings implements PersistentStateComponent { myBundledDisabledDictionariesPaths = bundledDisabledDictionariesPaths; } + @SuppressWarnings({"ConstantConditions"}) public Element getState() { + if (myBundledDisabledDictionariesPaths.size() == 0 && + myDictionaryFoldersPaths.size() == 0 && + myDisabledDictionariesPaths.size() == 0) { + return null; + } + final Element element = new Element(SPELLCHECKER_MANAGER_SETTINGS_TAG); // bundled element.setAttribute(BUNDLED_DICTIONARIES_ATTR_NAME, String.valueOf(myBundledDisabledDictionariesPaths.size())); @@ -156,8 +133,7 @@ public class SpellCheckerSettings implements PersistentStateComponent { myDisabledDictionariesPaths.add(element.getAttributeValue(DICTIONARY_ATTR_NAME + i)); } } - catch (Exception e) { - // ignore + catch (Exception ignored) { } } }