diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java index b17b0351b8a..d5d73f56cb3 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java @@ -635,8 +635,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); } } @@ -701,9 +699,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); - // TODO - drill to the entries } } @@ -774,9 +769,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); - // TODO - drill to the entries } { ICConfigurationDescription[] cfgDescriptions = prjDescription_2.getConfigurations(); @@ -935,8 +927,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); } } @@ -1014,9 +1004,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); - // TODO - drill to the entries } // Change the provider's entries back (bug was found for this case) { @@ -1052,9 +1039,6 @@ public class LanguageSettingsListenersTests extends TestCase { assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); - assertEquals(1, event.getResources(cfgDescriptionId).length); - assertEquals(project, event.getResources(cfgDescriptionId)[0]); - // TODO - drill to the entries } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ILanguageSettingsChangeEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ILanguageSettingsChangeEvent.java index c609aad9a07..63b07601810 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ILanguageSettingsChangeEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ILanguageSettingsChangeEvent.java @@ -11,26 +11,28 @@ package org.eclipse.cdt.internal.core.language.settings.providers; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; -import org.eclipse.core.resources.IResource; /** * Contains the details of changes that occurred as a result of modifying - * language settings entries {@link ICLanguageSettingEntry}. - * + * language settings entries {@link ICLanguageSettingEntry}. The event is + * associated with a project. + * + * API notes: this interface probably is not stable yet as it is not currently + * clear how it may need to be used in future. Only bare minimum is provided + * here at this point. + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ILanguageSettingsChangeEvent { + /** + * @return project name where the event occurred. + */ public String getProjectName(); - + + /** + * @return configuration IDs which are affected by the language settings changes. + */ public String[] getConfigurationDescriptionIds(); - - public IResource[] getResources(String cfgDescriptionId); - -// // AG - YAGNI -// public List getSettingEntriesOld(ICConfigurationDescription cfgDescription, IResource rc, String languageId); -// public List getSettingEntriesNew(ICConfigurationDescription cfgDescription, IResource rc, String languageId); -// // AG - or maybe -// ILanguageSettingsDelta getDelta(ICConfigurationDescription cfgDescription); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java index 3cc23505630..4b88f99e6cf 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java @@ -10,29 +10,19 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.language.settings.providers; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; -import org.eclipse.cdt.core.settings.model.ICSettingEntry; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.Assert; -// TODO possibly make an interface from that +/** + * This class currently is a placeholder holding old and new states. + * If more details need to be pulled out of delta, it could be elaborated further. + */ public class LanguageSettingsDelta { // maps need to be ordered by providers + @SuppressWarnings("unused") private LinkedHashMap oldLanguageSettingsState; + @SuppressWarnings("unused") private LinkedHashMap newLanguageSettingsState; @@ -41,115 +31,4 @@ public class LanguageSettingsDelta { newLanguageSettingsState = newState; } - // FIXME - this API is no good - public Set getChangedResources(IProject project, ICConfigurationDescription cfgDescription) { - Set resources = new HashSet(); - - // Ordered collections - Collection oldStateStorages = oldLanguageSettingsState.values(); - Collection newStateStorages = newLanguageSettingsState.values(); - - for (LanguageSettingsStorage lss : oldStateStorages) { -// Map>> - Map>> mapInternal = lss.getMapInternal(); - synchronized (mapInternal) { - for (Entry>> entryLang : mapInternal.entrySet()) { - String langId = entryLang.getKey(); - for (Entry> entryRc : entryLang.getValue().entrySet()) { - String rcName = entryRc.getKey(); - IResource rc = (rcName != null) ? project.findMember(rcName) : project; - if (resources.contains(rc)) - continue; - - List lsEntriesOld = entryRc.getValue(); - List lsEntriesNew = getSettingEntries(newStateStorages, cfgDescription, rc, langId); - - if (!lsEntriesNew.equals(lsEntriesOld) && !(lsEntriesOld==null && lsEntriesNew.size()==0)) { - resources.add(rc); - } - } - } - } - } - for (LanguageSettingsStorage lss : newStateStorages) { -// Map>> - Map>> mapInternal = lss.getMapInternal(); - synchronized (mapInternal) { - for (Entry>> entryLang : mapInternal.entrySet()) { - String langId = entryLang.getKey(); - for (Entry> entryRc : entryLang.getValue().entrySet()) { - String rcName = entryRc.getKey(); - IResource rc = (rcName != null) ? project.findMember(rcName) : project; - if (resources.contains(rc)) - continue; - - List lsEntriesNew = entryRc.getValue(); - List lsEntriesOld = getSettingEntries(oldStateStorages, cfgDescription, rc, langId); - - if (!lsEntriesOld.equals(lsEntriesNew) && !(lsEntriesNew==null && lsEntriesOld.size()==0)) { - resources.add(rc); - } - } - } - } - } - - return resources; - } - - private static boolean checkBit(int flags, int bit) { - return (flags & bit) == bit; - } - - private static List getSettingEntries(Collection stores, ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - List entries = new ArrayList(); - List alreadyAdded = new ArrayList(); - - for (LanguageSettingsStorage store: stores) { - List providerEntries = getSettingEntriesUpResourceTree(store, cfgDescription, rc, languageId); - for (ICLanguageSettingEntry entry : providerEntries) { - if (entry!=null) { - String entryName = entry.getName(); - // Only first entry is considered - // Entry flagged as "UNDEFINED" prevents adding entry with the same name down the line - if (!alreadyAdded.contains(entryName)) { - int flags = entry.getFlags(); - if (!checkBit(flags, ICSettingEntry.UNDEFINED)) { - entries.add(entry); - } - alreadyAdded.add(entryName); - } - } - } - } - - return entries; - } - - private static List getSettingEntriesUpResourceTree(LanguageSettingsStorage store, ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - Assert.isTrue( !(rc instanceof IWorkspaceRoot) ); - if (store!=null) { - List entries = store.getSettingEntries(cfgDescription, rc, languageId); - if (entries!=null) { - return new ArrayList(entries); - } - if (rc!=null) { - IResource parentFolder = (rc instanceof IProject) ? null : rc.getParent(); - if (parentFolder!=null) { - return getSettingEntriesUpResourceTree(store, cfgDescription, parentFolder, languageId); - } - // if out of parent resources - get default entries for the applicable language scope - entries = store.getSettingEntries(null, null, languageId); - if (entries!=null) { - return new ArrayList(entries); - } - } - } - - return new ArrayList(0); - } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index 12450b5784d..61465c6d0c7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -33,7 +33,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IContainer; @@ -179,8 +178,6 @@ public class LanguageSettingsProvidersSerializer { private String projectName = null; private Map deltaMap = new HashMap(); - private IResource[] resources = null; - /** * The act of creating event resets internal delta count in configuration state. * That implies that when the event is retrieved it must be fired or delta will go missing. @@ -208,7 +205,6 @@ public class LanguageSettingsProvidersSerializer { CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, ss.getMessage(), new CoreException(ss))); } } - } } @@ -217,26 +213,9 @@ public class LanguageSettingsProvidersSerializer { } public String[] getConfigurationDescriptionIds() { - String[] ids = deltaMap.keySet().toArray(new String[deltaMap.size()]); - return ids; + return deltaMap.keySet().toArray(new String[deltaMap.size()]); } - public IResource[] getResources(String cfgDescriptionId) { - if (resources == null) { - LanguageSettingsDelta delta = deltaMap.get(cfgDescriptionId); - if (delta == null) { - resources = new IResource[0]; - } else { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); - ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); - resources = delta.getChangedResources(project, cfgDescription).toArray(new IResource[0]); - } - } - - return resources; - } - @Override public String toString() { return "LanguageSettingsChangeEvent for project=[" + getProjectName() + "]"