Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-02-28 00:51:31 +0000
committerMikhail Sennikovsky2007-02-28 00:51:31 +0000
commit5727eccf3e503a4daa42b9ad2970aa6d899cea43 (patch)
treeb09732a78a90dbeaf3ab52eb3c0f94cb2c82f484
parent77a8e0ef9cd6c8d123701bdfd206fb64abbc2072 (diff)
downloadorg.eclipse.cdt-5727eccf3e503a4daa42b9ad2970aa6d899cea43.tar.gz
org.eclipse.cdt-5727eccf3e503a4daa42b9ad2970aa6d899cea43.tar.xz
org.eclipse.cdt-5727eccf3e503a4daa42b9ad2970aa6d899cea43.zip
Fix to [Bug 175581] Includes path entry not filled out with envVarBuildPath
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java15
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java226
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/SettingsSet.java215
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java26
7 files changed, 426 insertions, 69 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java
index 6c54be83b2f..f74a1b41824 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
@@ -411,6 +412,10 @@ public class BuildLanguageData extends CLanguageData {
}
return null;
}
+
+ public IConfiguration getConfiguration(){
+ return fTool.getParentResourceInfo().getParent();
+ }
public void setSourceContentTypeIds(String[] ids) {
String[] headerIds = fInputType.getHeaderContentTypeIds();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java
index 9275ad62e7a..cfc562c3ee8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
@@ -126,6 +127,8 @@ public class BuildVariablesContributor implements ICdtVariablesContributor {
private ContributorMacroContextInfo createContextInfo(ICdtVariableManager mngr){
IConfiguration cfg = fCfgData.getConfiguration();
+ if(((Configuration)cfg).isPreference())
+ return null;
IProject project = cfg.getOwner().getProject();
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project);
if(des != null){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java
index cbaf65f9fc1..61cdb6059ae 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java
@@ -11,20 +11,33 @@
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
public class EntryInfo {
private ICLanguageSettingEntry fEntry;
+ private EntryNameKey fNameKey;
// private IOption fOption;
// private String fEnvVarName;
// private int fPosition;
private boolean fIsDiscovered;
private boolean fIsOverRidden;
- EntryInfo(ICLanguageSettingEntry entry, boolean discovered, boolean isOverridden){
+ EntryInfo(ICLanguageSettingEntry entry){
+ fEntry = entry;
+ }
+
+/* EntryInfo(ICLanguageSettingEntry entry, boolean discovered, boolean isOverridden){
fEntry = entry;
fIsDiscovered = discovered;
fIsOverRidden = isOverridden;
}
+*/
+ public EntryNameKey getNameKey(){
+ if(fNameKey == null){
+ fNameKey = new EntryNameKey(fEntry);
+ }
+ return fNameKey;
+ }
/* EntryInfo(ICLanguageSettingEntry entry, boolean discovered, IOption option, int position){
fEntry = entry;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java
index 1be6c5d1010..9ae08394a9a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java
@@ -28,8 +28,7 @@ public class EntryListMap {
}
public void addEntryInfo(EntryInfo info){
- ICLanguageSettingEntry entry = info.getEntry();
- EntryNameKey key = new EntryNameKey(entry);
+ EntryNameKey key = info.getNameKey();
EntryInfo old = (EntryInfo)fMap.remove(key);
if(old != null)
fList.remove(old);
@@ -60,7 +59,7 @@ public class EntryListMap {
}
public void remove() {
- fMap.remove(new EntryNameKey(((EntryInfo)fCurrent).getEntry()));
+ fMap.remove(((EntryInfo)fCurrent).getNameKey());
fIter.remove();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java
index 459670c11fb..c5e8320f84e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java
@@ -11,9 +11,8 @@
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
@@ -23,19 +22,22 @@ import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
-import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.SettingsSet.SettingLevel;
public class EntryStorage {
private int fKind;
- private EntryListMap fDiscoveredEntries = new EntryListMap();
- private EntryListMap fUserEntries = new EntryListMap();
+ private SettingsSet fSettings;
+// private EntryListMap fDiscoveredEntries = new EntryListMap();
+// private EntryListMap fUserEntries = new EntryListMap();
// private ICLanguageSettingEntry fEntries[];
private BuildLanguageData fLangData;
private boolean fCacheInited;
@@ -61,16 +63,18 @@ public class EntryStorage {
if(list == null)
list = new ArrayList();
- for(Iterator iter = fUserEntries.getIterator(); iter.hasNext();){
- EntryInfo info = (EntryInfo)iter.next();
+ ICLanguageSettingEntry entries[] = fSettings.getEntries();
+ list.addAll(Arrays.asList(entries));
+// for(Iterator iter = fUserEntries.getIterator(); iter.hasNext();){
+// EntryInfo info = (EntryInfo)iter.next();
+//// if(!info.isOverridden())
+// list.add(info.getEntry());
+// }
+// for(Iterator iter = fDiscoveredEntries.getIterator(); iter.hasNext();){
+// EntryInfo info = (EntryInfo)iter.next();
// if(!info.isOverridden())
- list.add(info.getEntry());
- }
- for(Iterator iter = fDiscoveredEntries.getIterator(); iter.hasNext();){
- EntryInfo info = (EntryInfo)iter.next();
- if(!info.isOverridden())
- list.add(info.getEntry());
- }
+// list.add(info.getEntry());
+// }
return list;
}
@@ -97,37 +101,37 @@ public class EntryStorage {
return;
}
initCache();
- ArrayList userList = new ArrayList();
- Map discoveredMap = fDiscoveredEntries.getEntryInfoMap();
- boolean discoveredReadOnly = isDiscoveredEntriesReadOnly();
- for(int i = 0; i < entries.length; i++){
- ICLanguageSettingEntry entry = entries[i];
- EntryInfo info = (EntryInfo)discoveredMap.remove(new EntryNameKey(entry));
- if(info == null || info.isOverridden() || !discoveredReadOnly){
- if(info != null){
- info.makeOverridden(true);
- }
- ICLanguageSettingEntry usrEntry = createEntry(entry, false);
- userList.add(usrEntry);
- }
- }
+ fSettings.applyEntries(entries);
+// ArrayList userList = new ArrayList();
+// Map discoveredMap = fDiscoveredEntries.getEntryInfoMap();
+// boolean discoveredReadOnly = isDiscoveredEntriesReadOnly();
+//
+// for(int i = 0; i < entries.length; i++){
+// ICLanguageSettingEntry entry = entries[i];
+// EntryInfo info = (EntryInfo)discoveredMap.remove(new EntryNameKey(entry));
+// if(info == null || info.isOverridden() || !discoveredReadOnly){
+// if(info != null){
+// info.makeOverridden(true);
+// }
+// ICLanguageSettingEntry usrEntry = createEntry(entry, false);
+// userList.add(usrEntry);
+// }
+// }
- for(Iterator iter = discoveredMap.values().iterator(); iter.hasNext();){
- EntryInfo info = (EntryInfo)iter.next();
- info.makeOverridden(false);
- }
+// for(Iterator iter = discoveredMap.values().iterator(); iter.hasNext();){
+// EntryInfo info = (EntryInfo)iter.next();
+// info.makeOverridden(false);
+// }
+ SettingLevel level = fSettings.getLevels()[0];
+ ICLanguageSettingEntry usrEntries[] = level.getEntries();
IOption options[] = fLangData.getOptionsForKind(fKind);
- fUserEntries.clear();
if(options.length > 0){
IOption option = options[0];
- int size = userList.size();
- String optValue[] = new String[size];
- for(int i = 0; i < size; i++){
- ICLanguageSettingEntry entry = (ICLanguageSettingEntry)userList.get(i);
- EntryInfo info = new EntryInfo(entry, false, true);
- fUserEntries.addEntryInfo(info);
+ String optValue[] = new String[usrEntries.length];
+ for(int i = 0; i < usrEntries.length; i++){
+ ICLanguageSettingEntry entry = usrEntries[i];
optValue[i] = entryValueToOption(entry);
}
@@ -154,23 +158,91 @@ public class EntryStorage {
// }
//
// } else {
+ fSettings = createEmptySettings();
+ SettingLevel levels[] = fSettings.getLevels();
fCacheInited = true;
DiscoveredEntry[] dEntries = fLangData.getDiscoveredEntryValues(fKind);
- fDiscoveredEntries.clear();
- boolean readOnly = isDiscoveredEntriesReadOnly();
- if(dEntries.length != 0){
- for(int i = 0; i < dEntries.length; i++){
- DiscoveredEntry dEntry = dEntries[i];
- ICLanguageSettingEntry entry = createEntry(dEntry, true, readOnly);
- EntryInfo info = new EntryInfo(entry, true, false);
- fDiscoveredEntries.addEntryInfo(info);
- }
- }
- initUserValues();
- fUserValuesInited = true;
+ addEntries(levels[2], dEntries);
+
+ dEntries = getDiscoveredEnvironmentEntries();
+ addEntries(levels[1], dEntries);
+
+ dEntries = getUserDiscoveredEntries();
+ addEntries(levels[0], dEntries);
+
+ fSettings.adjustOverrideState();
+//// fDiscoveredEntries.clear();
+// boolean readOnly = isDiscoveredEntriesReadOnly();
+// if(dEntries.length != 0){
+// SettingLevel level = levels[2];
+// for(int i = 0; i < dEntries.length; i++){
+// DiscoveredEntry dEntry = dEntries[i];
+// ICLanguageSettingEntry entry = createEntry(dEntry, true, readOnly);
+// level.addEntry(entry);
+//// EntryInfo info = new EntryInfo(entry, true, false);
+//// fDiscoveredEntries.addEntryInfo(info);
+// }
+// }
+// initUserValues();
+// fUserValuesInited = true;
// }
}
+ private void addEntries(SettingLevel level, DiscoveredEntry dEntries[]){
+ if(dEntries.length != 0){
+ for(int i = 0; i < dEntries.length; i++){
+ DiscoveredEntry dEntry = dEntries[i];
+ ICLanguageSettingEntry entry = createEntry(dEntry);
+ level.addEntry(entry);
+ }
+ }
+ }
+
+ private DiscoveredEntry[] getDiscoveredEnvironmentEntries(){
+ String paths[] = null;
+ switch(fKind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:{
+ IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
+ paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE);
+ }
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:{
+ IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
+ paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_LIBRARY);
+ }
+ break;
+ }
+
+ if(paths != null && paths.length != 0){
+ DiscoveredEntry entries[] = new DiscoveredEntry[paths.length];
+ for(int i = 0; i < paths.length; i++){
+ entries[i] = new DiscoveredEntry(paths[i]);
+ }
+
+ return entries;
+ }
+ return new DiscoveredEntry[0];
+ }
+
+ private SettingsSet createEmptySettings(){
+ SettingsSet settings = new SettingsSet(3);
+ SettingLevel levels[] = settings.getLevels();
+
+ levels[0].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
+ levels[0].setFlagsToSet(0);
+ levels[0].setReadOnly(false);
+
+ levels[1].setFlagsToClear(ICSettingEntry.BUILTIN);
+ levels[1].setFlagsToSet(ICSettingEntry.READONLY);
+ levels[1].setReadOnly(true);
+
+ levels[2].setFlagsToClear(0);
+ levels[2].setFlagsToSet(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
+ levels[2].setReadOnly(true);
+
+ return settings;
+ }
+
private boolean isDiscoveredEntriesReadOnly(){
if(fKind == ICLanguageSettingEntry.MACRO){
return fLangData.getOptionsForKind(fKind).length != 0;
@@ -178,10 +250,39 @@ public class EntryStorage {
return true;
}
- private void initUserValues(){
+// private void initUserValues(){
+// IOption options[] = fLangData.getOptionsForKind(fKind);
+// fUserEntries.clear();
+// if(options.length > 0){
+// for(int i = 0; i < options.length; i++){
+// IOption option = options[i];
+// List list = (List)option.getValue();
+// int size = list.size();
+// if(size > 0){
+// for(int j = 0; j < size; j++){
+// String value = (String)list.get(j);
+// if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
+// value = value.substring(1, value.length() - 1);
+// }
+// ICLanguageSettingEntry entry = createEntry(discoveredEntryFromString(value), false, false);
+// EntryInfo discoveredInfo = fDiscoveredEntries.getEntryInfo(entry);
+// if(discoveredInfo != null){
+//// discoveredInfo.setOptionInfo(option, j);
+// discoveredInfo.makeOverridden(true);
+// }
+// EntryInfo userInfo = new EntryInfo(entry, false, true);
+// fUserEntries.addEntryInfo(userInfo);
+// }
+// }
+//
+// }
+// }
+// }
+
+ private DiscoveredEntry[] getUserDiscoveredEntries(){
IOption options[] = fLangData.getOptionsForKind(fKind);
- fUserEntries.clear();
if(options.length > 0){
+ List entryList = new ArrayList();
for(int i = 0; i < options.length; i++){
IOption option = options[i];
List list = (List)option.getValue();
@@ -192,19 +293,14 @@ public class EntryStorage {
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
value = value.substring(1, value.length() - 1);
}
- ICLanguageSettingEntry entry = createEntry(discoveredEntryFromString(value), false, false);
- EntryInfo discoveredInfo = fDiscoveredEntries.getEntryInfo(entry);
- if(discoveredInfo != null){
-// discoveredInfo.setOptionInfo(option, j);
- discoveredInfo.makeOverridden(true);
- }
- EntryInfo userInfo = new EntryInfo(entry, false, true);
- fUserEntries.addEntryInfo(userInfo);
+ entryList.add(discoveredEntryFromString(value));
}
}
-
}
+
+ return (DiscoveredEntry[])entryList.toArray(new DiscoveredEntry[entryList.size()]);
}
+ return new DiscoveredEntry[0];
}
private DiscoveredEntry discoveredEntryFromString(String str){
@@ -225,9 +321,9 @@ public class EntryStorage {
return entriesList;
}
*/
- private ICLanguageSettingEntry createEntry(DiscoveredEntry dEntry, boolean discovered, boolean readOnly){
+ private ICLanguageSettingEntry createEntry(DiscoveredEntry dEntry/*, boolean discovered, boolean readOnly*/){
ICLanguageSettingEntry entry = null;
- int flags = discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0;
+ int flags = 0;//discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0;
Object v[];
String value = dEntry.getValue();
String name = dEntry.getName();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/SettingsSet.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/SettingsSet.java
new file mode 100644
index 00000000000..74ebc1faadd
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/SettingsSet.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
+
+public class SettingsSet {
+ public static final int READ_ONLY = 1;
+ public static final int WRITABLE = 1 << 1;
+
+ private SettingLevel[] fLevels;
+ public class SettingLevel {
+ private int fFlagsToSet;
+ private int fFlagsToClear;
+ private boolean fIsReadOnly;
+ private EntryListMap fEntries;
+
+ private SettingLevel(){
+ fEntries = new EntryListMap();
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ public void setReadOnly(boolean readOnly){
+ fIsReadOnly = readOnly;
+ }
+
+ public void setFlagsToSet(int flags){
+ fFlagsToSet = flags;
+ }
+
+ public void setFlagsToClear(int flags){
+ fFlagsToClear = flags;
+ }
+
+ public int getFlagsToSet(){
+ return fFlagsToSet;
+ }
+
+ public int getFlagsToClear(){
+ return fFlagsToClear;
+ }
+
+ public void addEntry(ICLanguageSettingEntry entry){
+ entry = CDataUtil.createEntry(entry, fFlagsToSet, fFlagsToClear);
+ fEntries.addEntryInfo(new EntryInfo(entry));
+ }
+
+ public void clear(){
+ fEntries.clear();
+ }
+
+ EntryInfo[] getInfos(){
+ return fEntries.getEntries();
+ }
+
+ public ICLanguageSettingEntry[] getEntries(){
+ List list = new ArrayList();
+ EntryInfo infos[] = getInfos();
+ for(int i = 0; i < infos.length; i++){
+ if(!infos[i].isOverridden())
+ list.add(infos[i].getEntry());
+ }
+
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+
+
+ }
+
+ public SettingsSet(int num){
+ fLevels = new SettingLevel[num];
+ for(int i = 0; i < num; i++){
+ fLevels[i] = new SettingLevel();
+ }
+ }
+
+ public SettingLevel[] getLevels(){
+ return (SettingLevel[])fLevels.clone();
+ }
+
+ public void adjustOverrideState(){
+ Set set = new HashSet();
+ for(int i = 0; i < fLevels.length; i++){
+ adjustOverrideState(fLevels[i], set);
+ }
+ }
+
+ private void adjustOverrideState(SettingLevel level, Set overridenSet){
+ EntryInfo[] infos = level.getInfos();
+ EntryInfo info;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ if(overridenSet.add(info.getNameKey())){
+ info.makeOverridden(false);
+ } else {
+ info.makeOverridden(true);
+ }
+ }
+ }
+
+ public ICLanguageSettingEntry[] getEntries(){
+ return getEntries(READ_ONLY | WRITABLE);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int types){
+ adjustOverrideState();
+ List entries = new ArrayList();
+ for(int i = 0; i < fLevels.length; i++){
+ if(isCompatible(fLevels[i], types))
+ getEntries(fLevels[i], entries);
+ }
+
+ return (ICLanguageSettingEntry[])entries.toArray(new ICLanguageSettingEntry[entries.size()]);
+ }
+
+ private void getEntries(SettingLevel level, List list){
+ EntryInfo[] infos = level.getInfos();
+ EntryInfo info;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ if(!info.isOverridden())
+ list.add(info.getEntry());
+ }
+ }
+
+ private boolean isCompatible(SettingLevel level, int types){
+ if((types & READ_ONLY) == 0 && level.isReadOnly())
+ return false;
+ if((types & WRITABLE) == 0 && !level.isReadOnly())
+ return false;
+
+ return true;
+ }
+
+ private int getDefaultLevelNum(){
+ for(int i = 0; i <fLevels.length; i++){
+ if(!fLevels[i].isReadOnly())
+ return i;
+ }
+
+ return 0;
+ }
+
+ public void applyEntries(ICLanguageSettingEntry[] entries){
+ Map map = getEntryLevelMap(WRITABLE | READ_ONLY);
+
+ for(int i = 0; i < fLevels.length; i++){
+ if(!fLevels[i].isReadOnly()){
+ fLevels[i].clear();
+ }
+ }
+
+ Integer levelInteger;
+ int levelNum;
+ EntryNameKey key;
+ ICLanguageSettingEntry entry;
+ int defaultLevel = getDefaultLevelNum();
+ SettingLevel level;
+
+ for(int i = 0; i < entries.length; i++){
+ entry = entries[i];
+ key = new EntryNameKey(entry);
+ levelInteger = (Integer)map.get(key);
+ levelNum = levelInteger != null ? levelInteger.intValue() : defaultLevel;
+ level = fLevels[levelNum];
+ if(!level.isReadOnly())
+ level.addEntry(entry);
+ }
+
+ adjustOverrideState();
+ }
+
+ public Map getEntryLevelMap(int types){
+ Map map = new HashMap();
+ for(int i = 0; i < fLevels.length; i++){
+ if(isCompatible(fLevels[i], types))
+ addLevelInfoToMap(fLevels[i], i, map);
+ }
+
+ return map;
+
+ }
+
+ private void addLevelInfoToMap(SettingLevel level, int l, Map map){
+ EntryInfo infos[] = level.getInfos();
+ EntryInfo info;
+ EntryNameKey key;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ key = info.getNameKey();
+ if(!map.containsKey(key))
+ map.put(key, new Integer(l));
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
index c05320b6c0d..17be0a5fc6c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
@@ -137,5 +137,31 @@ public class CDataUtil {
}
}
+ public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear){
+ return createEntry(entry, (entry.getFlags() | flagsToAdd) & (~flafsToClear));
+ }
+ public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flags){
+ switch (entry.getKind()){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ entry = new CIncludePathEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.MACRO:
+ entry = new CMacroEntry(entry.getName(), entry.getValue(), flags);
+ break;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ entry = new CIncludeFileEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ entry = new CMacroFileEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ entry = new CLibraryPathEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ entry = new CLibraryFileEntry(entry.getName(), flags);
+ break;
+ }
+ return entry;
+ }
}

Back to the top