From bb44d4020d5db4b6fcfb946dd160f60b15971dfa Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Thu, 31 Jan 2008 16:22:58 +0000 Subject: Bug #182450 : Multi-cfg Bug #217253 : Project Wizard head --- .../cdt/core/settings/model/ICLanguageSetting.java | 4 +- .../cdt/core/settings/model/util/EntryStore.java | 81 ++++++++++------------ .../core/settings/model/CLanguageSetting.java | 16 ++--- .../core/settings/model/CLanguageSettingCache.java | 4 +- .../core/settings/model/MultiLanguageSetting.java | 8 +-- 5 files changed, 53 insertions(+), 60 deletions(-) (limited to 'core/org.eclipse.cdt.core/model/org') diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java index 812ee3d246e..2788a2f29fd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java @@ -31,7 +31,7 @@ public interface ICLanguageSetting extends ICSettingObject { ICLanguageSettingEntry[] getSettingEntries(int kind); - List getSettingEntriesList(int kind); + List getSettingEntriesList(int kind); // ICLanguageSettingEntry[] getResolvedSettingEntries(); @@ -39,7 +39,7 @@ public interface ICLanguageSetting extends ICSettingObject { void setSettingEntries(int kind, ICLanguageSettingEntry[] entries); - void setSettingEntries(int kind, List entriesList); + void setSettingEntries(int kind, List entriesList); // void changeEntries(ICLanguageSettingEntryInfo[] added, ICLanguageSettingEntry[] removed); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java index f07e8a7c5c7..4cf86de2ead 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.core.settings.model.util; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -24,7 +23,6 @@ import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry; import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry; import org.eclipse.cdt.core.settings.model.ICMacroEntry; import org.eclipse.cdt.core.settings.model.ICMacroFileEntry; -import org.eclipse.cdt.core.settings.model.ICSettingEntry; public class EntryStore { private KindBasedStore fStore = new KindBasedStore(); @@ -39,40 +37,35 @@ public class EntryStore { } public EntryStore(EntryStore base, boolean preserveReadOnly){ - int kinds[] = KindBasedStore.getLanguageEntryKinds(); - int kind; - for(int i = 0; i < kinds.length; i++){ - kind = kinds[i]; - ArrayList list = (ArrayList)fStore.get(kind); + for(int kind : KindBasedStore.getLanguageEntryKinds()){ + ArrayList list = (ArrayList)fStore.get(kind); if(list != null) - fStore.put(kind, (ArrayList)list.clone()); + fStore.put(kind, (ArrayList)list.clone()); } fPreserveReadOnly = preserveReadOnly; } + @SuppressWarnings("unchecked") public ICLanguageSettingEntry[] getEntries(){ - int kinds[] = KindBasedStore.getLanguageEntryKinds(); - List result = new ArrayList(); - List list; - for(int i = 0; i < kinds.length; i++){ - list = (List)fStore.get(kinds[i]); + List result = new ArrayList(); + List list; + for(int k: KindBasedStore.getLanguageEntryKinds()){ + list = (List)fStore.get(k); if(list != null) result.addAll(list); } - - return (ICLanguageSettingEntry[])result.toArray(new ICLanguageSettingEntry[result.size()]); + return result.toArray(new ICLanguageSettingEntry[result.size()]); } public boolean containsEntriesList(int kind){ - List list = getEntriesList(kind, false); + List list = getEntriesList(kind, false); return list != null; } public ICLanguageSettingEntry[] getEntries(int kind){ - List list = getEntriesList(kind); -// if(list != null){ + List list = getEntriesList(kind); if(list == null) - list = new ArrayList(0); + list = new ArrayList(0); switch(kind){ case ICLanguageSettingEntry.INCLUDE_PATH: return (ICLanguageSettingEntry[])list.toArray(new ICIncludePathEntry[list.size()]); @@ -89,25 +82,24 @@ public class EntryStore { default: throw new IllegalArgumentException(); } -// } -// return null; } - public List getEntriesList(int kind){ - List list = getEntriesList(kind, false); + public List getEntriesList(int kind){ + List list = getEntriesList(kind, false); if(list != null) - return new ArrayList(list); - return new ArrayList(0); + return new ArrayList(list); + return new ArrayList(0); } - private void setEntriesList(int kind, List list){ + private void setEntriesList(int kind, List list){ fStore.put(kind, list); } - private List getEntriesList(int kind, boolean create){ - List list = (List)fStore.get(kind); + @SuppressWarnings("unchecked") + private List getEntriesList(int kind, boolean create){ + List list = (List)fStore.get(kind); if(list == null && create){ - fStore.put(kind, list = new ArrayList()); + fStore.put(kind, list = new ArrayList()); } return list; } @@ -117,7 +109,7 @@ public class EntryStore { // } public void addEntry(int pos, ICLanguageSettingEntry entry){ - List list = getEntriesList(entry.getKind(), true); + List list = getEntriesList(entry.getKind(), true); if(pos >= list.size()) list.add(entry); else @@ -131,19 +123,21 @@ public class EntryStore { } public void storeEntries(int kind, ICLanguageSettingEntry[] entries){ - storeEntries(kind, entries != null ? Arrays.asList(entries) : new ArrayList()); + storeEntries(kind, + entries != null ? + Arrays.asList(entries) : + new ArrayList()); } - public void storeEntries(int kind, List list){ - List newList = new ArrayList(list); + public void storeEntries(int kind, List list){ + List newList = new ArrayList(list); // newList.addAll(Arrays.asList(entries)); if(fPreserveReadOnly){ - List oldList = getEntriesList(kind, false); + List oldList = getEntriesList(kind, false); if(oldList != null){ - Set ro = getReadOnlySet(oldList); + Set ro = getReadOnlySet(oldList); ro.removeAll(newList); - for(Iterator iter = oldList.iterator(); iter.hasNext();){ - Object o = iter.next(); + for(ICLanguageSettingEntry o : oldList){ if(ro.contains(o)) newList.add(o); } @@ -152,10 +146,9 @@ public class EntryStore { setEntriesList(kind, newList); } - private Set getReadOnlySet(List entries){ - Set set = new HashSet(); - for(Iterator iter = entries.iterator(); iter.hasNext();){ - ICSettingEntry entry = (ICSettingEntry)iter.next(); + private Set getReadOnlySet(List entries){ + Set set = new HashSet(); + for(ICLanguageSettingEntry entry : entries){ if(entry.isReadOnly()) set.add(entry); } @@ -163,14 +156,16 @@ public class EntryStore { } public void addEntry(ICLanguageSettingEntry entry){ - List list = getEntriesList(entry.getKind(), true); + List list = getEntriesList(entry.getKind(), true); list.add(entry); } + @SuppressWarnings("unchecked") public void trimToSize(){ int kinds[] = KindBasedStore.getLanguageEntryKinds(); for(int i = 0; i < kinds.length; i++){ - ArrayList list = (ArrayList)fStore.get(kinds[i]); + ArrayList list = + (ArrayList)fStore.get(kinds[i]); if(list != null) list.trimToSize(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java index d343de46e81..8dabb0dddb9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.settings.model; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; @@ -62,11 +61,11 @@ public class CLanguageSetting extends CDataProxy implements return data.getEntries(kind); } - public List getSettingEntriesList(int kind) { + public List getSettingEntriesList(int kind) { CLanguageData data = getCLanguageData(false); ICLanguageSettingEntry entries[] = data.getEntries(kind); int size = entries != null ? entries.length : 0; - List arrayList = new ArrayList(size); + List arrayList = new ArrayList(size); for(int i = 0; i < size; i++){ arrayList.add(entries[i]); } @@ -290,7 +289,7 @@ public class CLanguageSetting extends CDataProxy implements return result; } - public void setSettingEntries(int kind, List list) { + public void setSettingEntries(int kind, List list) { CLanguageData data = getCLanguageData(true); EntryStore store = new EntryStore(); // KindBasedStore nameSetStore = new KindBasedStore(); @@ -298,8 +297,7 @@ public class CLanguageSetting extends CDataProxy implements if(list != null){ if(list.size() != 0){ - for(Iterator iter = list.iterator(); iter.hasNext();){ - ICLanguageSettingEntry entry = (ICLanguageSettingEntry)iter.next(); + for(ICLanguageSettingEntry entry : list){ eKind = entry.getKind(); if((kind & eKind) != 0 && (data.getSupportedEntryKinds() & eKind) != 0){ store.addEntry(entry); @@ -307,9 +305,9 @@ public class CLanguageSetting extends CDataProxy implements } } else { int kinds[] = KindBasedStore.getLanguageEntryKinds(); - for(int i = 0; i < kinds.length; i++){ - if((kinds[i] & kind) != 0){ - store.storeEntries(kinds[i], new ICLanguageSettingEntry[0]); + for(int k : kinds){ + if((k & kind) != 0){ + store.storeEntries(k, new ICLanguageSettingEntry[0]); } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java index 58a3dd42c35..2cabeb2f3ee 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java @@ -113,7 +113,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements return fStore.getEntries(kind); } - public List getSettingEntriesList(int kind) { + public List getSettingEntriesList(int kind) { // int kinds[] = KindBasedStore.getSupportedKinds(); // List list = new ArrayList(); // for(int i = 0; i < kinds.length; i++){ @@ -135,7 +135,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements throw ExceptionFactory.createIsReadOnlyException(); } - public void setSettingEntries(int kind, List entriesList) { + public void setSettingEntries(int kind, List entriesList) { throw ExceptionFactory.createIsReadOnlyException(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java index 619bd86e642..9b5bee5737d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java @@ -26,12 +26,12 @@ import org.eclipse.cdt.core.settings.model.MultiItemsHolder; * Normally, they should have the same name. */ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting { - private static final Comparator comp = CDTListComparator.getInstance(); + private static final Comparator comp = CDTListComparator.getInstance(); ICLanguageSetting[] items = null; ICConfigurationDescription cfgd = null; - public MultiLanguageSetting(List data, ICConfigurationDescription cf) { + public MultiLanguageSetting(List data, ICConfigurationDescription cf) { items = (ICLanguageSetting[])data.toArray(new ICLanguageSetting[data.size()]); cfgd = cf; } @@ -73,7 +73,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSettingEntriesList(int) */ - public List getSettingEntriesList(int kind) { + public List getSettingEntriesList(int kind) { return Arrays.asList(getSettingEntries(kind)); } @@ -125,7 +125,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, java.util.List) */ - public void setSettingEntries(int kind, List entriesList) { + public void setSettingEntries(int kind, List entriesList) { for (int i=0; i