mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
Fix for [Bug 182573] tool specific optionPathConverter is no longer called when updating CDT 3.1.2 to CDT 4.0.0
This commit is contained in:
parent
72947a1a2e
commit
66c3bdc869
10 changed files with 480 additions and 1323 deletions
|
@ -54,8 +54,8 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildEntryStorage;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
|
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.EntryStorage;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
|
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
|
||||||
|
@ -4073,7 +4073,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
for(int i = 0; i < values.size(); i++){
|
for(int i = 0; i < values.size(); i++){
|
||||||
oVal = values.get(i);
|
oVal = values.get(i);
|
||||||
if(type == IOption.PREPROCESSOR_SYMBOLS){
|
if(type == IOption.PREPROCESSOR_SYMBOLS){
|
||||||
String[] nameVal = EntryStorage.macroNameValueFromValue((String)oVal);
|
String[] nameVal = BuildEntryStorage.macroNameValueFromValue((String)oVal);
|
||||||
oVal = nameVal[0];
|
oVal = nameVal[0];
|
||||||
}
|
}
|
||||||
if(filterSet.contains(oVal))
|
if(filterSet.contains(oVal))
|
||||||
|
|
|
@ -0,0 +1,332 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.settings.model.CMacroEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.AbstractEntryStorage;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.SettingsSet;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.SettingsSet.EntryInfo;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.SettingsSet.SettingLevel;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
|
private BuildLanguageData fLangData;
|
||||||
|
|
||||||
|
private static class UserEntryInfo {
|
||||||
|
private ICLanguageSettingEntry fEntry;
|
||||||
|
private String fOptionValue;
|
||||||
|
|
||||||
|
UserEntryInfo(ICLanguageSettingEntry entry, String optionValue){
|
||||||
|
fEntry = entry;
|
||||||
|
fOptionValue = optionValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BuildEntryStorage(int kind, BuildLanguageData lData) {
|
||||||
|
super(kind);
|
||||||
|
fLangData = lData;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SettingsSet createEmptySettings() {
|
||||||
|
SettingsSet settings = new SettingsSet(3);
|
||||||
|
SettingLevel levels[] = settings.getLevels();
|
||||||
|
|
||||||
|
boolean override = isDiscoveredEntriesOverridable();
|
||||||
|
int readOnlyFlag = override ? 0 : ICSettingEntry.READONLY;
|
||||||
|
levels[0].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
|
||||||
|
levels[0].setFlagsToSet(0);
|
||||||
|
levels[0].setReadOnly(false);
|
||||||
|
levels[0].setOverrideSupported(override);
|
||||||
|
|
||||||
|
levels[1].setFlagsToClear(ICSettingEntry.BUILTIN);
|
||||||
|
levels[1].setFlagsToSet(readOnlyFlag | ICSettingEntry.RESOLVED);
|
||||||
|
levels[1].setReadOnly(true);
|
||||||
|
levels[1].setOverrideSupported(false);
|
||||||
|
|
||||||
|
levels[2].setFlagsToClear(0);
|
||||||
|
levels[2].setFlagsToSet(readOnlyFlag | ICSettingEntry.BUILTIN | ICSettingEntry.RESOLVED);
|
||||||
|
levels[2].setReadOnly(true);
|
||||||
|
levels[2].setOverrideSupported(false);
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDiscoveredEntriesOverridable(){
|
||||||
|
return fLangData.getUndefOptionsForKind(getKind()).length != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
|
||||||
|
switch(levelNum){
|
||||||
|
case 0:
|
||||||
|
if(level == null)
|
||||||
|
restoreDefaults();
|
||||||
|
else {
|
||||||
|
EntryInfo infos[] = level.getInfos();
|
||||||
|
UserEntryInfo[] userInfos = new UserEntryInfo[infos.length];
|
||||||
|
for(int i = 0; i < infos.length; i++){
|
||||||
|
userInfos[i] = new UserEntryInfo(infos[i].getEntry(), (String)infos[i].getCustomInfo());
|
||||||
|
}
|
||||||
|
setUserEntries(userInfos);
|
||||||
|
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreDefaults(){
|
||||||
|
IOption options[] = fLangData.getOptionsForKind(getKind());
|
||||||
|
ITool tool = fLangData.getTool();
|
||||||
|
for(int i = 0; i < options.length; i++){
|
||||||
|
IOption option = options[i];
|
||||||
|
if(option.getParent() == tool){
|
||||||
|
tool.removeOption(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
options = fLangData.getUndefOptionsForKind(getKind());
|
||||||
|
for(int i = 0; i < options.length; i++){
|
||||||
|
IOption option = options[i];
|
||||||
|
if(option.getParent() == tool){
|
||||||
|
tool.removeOption(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void putEntriesToLevel(int levelNum, SettingLevel level) {
|
||||||
|
switch(levelNum){
|
||||||
|
case 0:
|
||||||
|
UserEntryInfo[] userEntries = getUserEntries(level.getFlags(0));
|
||||||
|
for(int i = 0; i < userEntries.length; i++){
|
||||||
|
level.addEntry(userEntries[i].fEntry, userEntries[i].fOptionValue);
|
||||||
|
}
|
||||||
|
level.addOverrideNameSet(getUserUndefinedStringSet());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ICLanguageSettingEntry[] envEntries = getEnvEntries(level.getFlags(0));
|
||||||
|
level.addEntries(envEntries);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ICLanguageSettingEntry[] discoveredEntries = getDiscoveredEntries(level.getFlags(0));
|
||||||
|
level.addEntries(discoveredEntries);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICLanguageSettingEntry[] getDiscoveredEntries(int flags){
|
||||||
|
return ProfileInfoProvider.getInstance().getEntryValues(fLangData, getKind(), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UserEntryInfo[] getUserEntries(int flags){
|
||||||
|
IOption options[] = fLangData.getOptionsForKind(getKind());
|
||||||
|
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();
|
||||||
|
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 = createUserEntry(value, flags);
|
||||||
|
entryList.add(new UserEntryInfo(entry, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (UserEntryInfo[])entryList.toArray(new UserEntryInfo[entryList.size()]);
|
||||||
|
}
|
||||||
|
return new UserEntryInfo[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet getUserUndefinedStringSet(){
|
||||||
|
HashSet set = null;
|
||||||
|
IOption options[] = fLangData.getUndefOptionsForKind(getKind());
|
||||||
|
if(options.length > 0){
|
||||||
|
for(int i = 0; i < options.length; i++){
|
||||||
|
IOption option = options[i];
|
||||||
|
List list = (List)option.getValue();
|
||||||
|
if(list.size() != 0){
|
||||||
|
if(set == null)
|
||||||
|
set = new HashSet();
|
||||||
|
set.addAll(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICLanguageSettingEntry[] getEnvEntries(int flags){
|
||||||
|
String paths[] = null;
|
||||||
|
int kind = getKind();
|
||||||
|
switch(kind){
|
||||||
|
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){
|
||||||
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[paths.length];
|
||||||
|
for(int i = 0; i < paths.length; i++){
|
||||||
|
entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, paths.toString(), null, null, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
return new ICLanguageSettingEntry[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICLanguageSettingEntry createUserEntry(String optionValue, int flags){
|
||||||
|
int kind = getKind();
|
||||||
|
|
||||||
|
ICLanguageSettingEntry entry = null;
|
||||||
|
|
||||||
|
switch (kind){
|
||||||
|
case ICLanguageSettingEntry.MACRO:
|
||||||
|
String nv[] = macroNameValueFromValue(optionValue);
|
||||||
|
|
||||||
|
entry = new CMacroEntry(nv[0], nv[1], flags);
|
||||||
|
break;
|
||||||
|
// case ICLanguageSettingEntry.INCLUDE_PATH:
|
||||||
|
// case ICLanguageSettingEntry.INCLUDE_FILE:
|
||||||
|
// case ICLanguageSettingEntry.MACRO_FILE:
|
||||||
|
// case ICLanguageSettingEntry.LIBRARY_PATH:
|
||||||
|
// case ICLanguageSettingEntry.LIBRARY_FILE:
|
||||||
|
default:
|
||||||
|
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
|
||||||
|
Object[] v = optionPathValueToEntry(optionValue);
|
||||||
|
String name = (String)v[0];
|
||||||
|
if(((Boolean)v[1]).booleanValue()){
|
||||||
|
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
||||||
|
} else if (optionPathConverter != null){
|
||||||
|
IPath path = optionPathConverter.convertToPlatformLocation(name, null, null);
|
||||||
|
if(path != null)
|
||||||
|
name = path.toString();
|
||||||
|
}
|
||||||
|
entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createOptionValue(UserEntryInfo info){
|
||||||
|
if(info.fOptionValue != null)
|
||||||
|
return info.fOptionValue;
|
||||||
|
|
||||||
|
return entryValueToOption(info.fEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String entryValueToOption(ICLanguageSettingEntry entry){
|
||||||
|
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
|
||||||
|
return new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
||||||
|
} else if(entry instanceof ICLanguageSettingPathEntry){
|
||||||
|
ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
|
||||||
|
if(pathEntry.isValueWorkspacePath()){
|
||||||
|
return ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entry.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String[] macroNameValueFromValue(String value){
|
||||||
|
String nv[] = new String[2];
|
||||||
|
int index = value.indexOf('=');
|
||||||
|
if(index > 0){
|
||||||
|
nv[0] = value.substring(0, index);
|
||||||
|
nv[1] = value.substring(index + 1);
|
||||||
|
} else {
|
||||||
|
nv[0] = value;
|
||||||
|
nv[1] = "";
|
||||||
|
}
|
||||||
|
return nv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object[] optionPathValueToEntry(String value){
|
||||||
|
String wspPath = ManagedBuildManager.locationToFullPath(value);
|
||||||
|
if(wspPath != null)
|
||||||
|
return new Object[]{wspPath, Boolean.valueOf(true)};
|
||||||
|
return new Object[]{value, Boolean.valueOf(false)};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUserEntries(UserEntryInfo[] entries){
|
||||||
|
int kind = getKind();
|
||||||
|
IOption options[] = fLangData.getOptionsForKind(kind);
|
||||||
|
if(options.length != 0){
|
||||||
|
IOption option = options[0];
|
||||||
|
String optValue[] = new String[entries.length];
|
||||||
|
if(entries.length != 0){
|
||||||
|
for(int i = 0; i < entries.length; i++){
|
||||||
|
optValue[i] = createOptionValue(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ITool tool = fLangData.getTool();
|
||||||
|
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
||||||
|
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
||||||
|
options = fLangData.getOptionsForKind(kind);
|
||||||
|
for(int i = 0; i < options.length; i++){
|
||||||
|
if(options[i] != newOption)
|
||||||
|
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUserUndefinedStringSet(Set set){
|
||||||
|
int kind = getKind();
|
||||||
|
IOption[] options = fLangData.getUndefOptionsForKind(kind);
|
||||||
|
if(options.length != 0){
|
||||||
|
if(set != null && set.size() == 0)
|
||||||
|
set = null;
|
||||||
|
|
||||||
|
String[] optValue = set != null ? (String[])set.toArray(new String[set.size()]) : new String[0];
|
||||||
|
IOption option = options[0];
|
||||||
|
ITool tool = fLangData.getTool();
|
||||||
|
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
||||||
|
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
||||||
|
options = fLangData.getUndefOptionsForKind(kind);
|
||||||
|
for(int i = 0; i < options.length; i++){
|
||||||
|
if(options[i] != newOption)
|
||||||
|
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void optionsChanged(){
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,7 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
|
import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
|
||||||
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
||||||
|
@ -33,7 +31,6 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
|
import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
|
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry;
|
|
||||||
|
|
||||||
public class BuildLanguageData extends CLanguageData {
|
public class BuildLanguageData extends CLanguageData {
|
||||||
private ITool fTool;
|
private ITool fTool;
|
||||||
|
@ -43,7 +40,7 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
private static final IOption[] EMPTY_OPTION_ARRAY = new IOption[0];
|
private static final IOption[] EMPTY_OPTION_ARRAY = new IOption[0];
|
||||||
private boolean fOptionStoreInited;
|
private boolean fOptionStoreInited;
|
||||||
// private Map fKindToEntryArrayMap = new HashMap();
|
// private Map fKindToEntryArrayMap = new HashMap();
|
||||||
private ProfileInfoProvider fDiscoveredInfo;
|
// private ProfileInfoProvider fDiscoveredInfo;
|
||||||
private KindBasedStore fKindToEntryStore = new KindBasedStore();
|
private KindBasedStore fKindToEntryStore = new KindBasedStore();
|
||||||
private String fId;
|
private String fId;
|
||||||
|
|
||||||
|
@ -68,32 +65,32 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
fId = new StringBuffer(fTool.getId()).append(".").append("languagedata").toString(); //$NON-NLS-1$ //$NON-NLS-2$
|
fId = new StringBuffer(fTool.getId()).append(".").append("languagedata").toString(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
fDiscoveredInfo = new ProfileInfoProvider(this);
|
// fDiscoveredInfo = new ProfileInfoProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void obtainEditableInputType(){
|
private void obtainEditableInputType(){
|
||||||
if(fInputType != null){
|
if(fInputType != null){
|
||||||
IInputType old = fInputType;
|
// IInputType old = fInputType;
|
||||||
fInputType = fTool.getEdtableInputType(fInputType);
|
fInputType = fTool.getEdtableInputType(fInputType);
|
||||||
if(old != fInputType){
|
// if(old != fInputType){
|
||||||
fDiscoveredInfo.checkUpdateInputType(fInputType);
|
// fDiscoveredInfo.checkUpdateInputType(fInputType);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
|
public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
|
||||||
EntryStorage storage = getEntryStorage(kind);
|
BuildEntryStorage storage = getEntryStorage(kind);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.setEntries(entries);
|
storage.setEntries(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntryStorage getEntryStorage(int kind){
|
private BuildEntryStorage getEntryStorage(int kind){
|
||||||
if(getOptionsForKind(kind).length == 0 && isToolChainDiscoveryProfile())
|
if(getOptionsForKind(kind).length == 0 && isToolChainDiscoveryProfile())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
EntryStorage starage = (EntryStorage)fKindToEntryStore.get(kind);
|
BuildEntryStorage starage = (BuildEntryStorage)fKindToEntryStore.get(kind);
|
||||||
if(starage == null){
|
if(starage == null){
|
||||||
starage = new EntryStorage(kind, this);
|
starage = new BuildEntryStorage(kind, this);
|
||||||
fKindToEntryStore.put(kind, starage);
|
fKindToEntryStore.put(kind, starage);
|
||||||
}
|
}
|
||||||
return starage;
|
return starage;
|
||||||
|
@ -101,7 +98,7 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
|
|
||||||
private void notifyOptionsChangeForKind(int kind){
|
private void notifyOptionsChangeForKind(int kind){
|
||||||
fOptionStoreInited = false;
|
fOptionStoreInited = false;
|
||||||
EntryStorage storage = getEntryStorage(kind);
|
BuildEntryStorage storage = getEntryStorage(kind);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.optionsChanged();
|
storage.optionsChanged();
|
||||||
}
|
}
|
||||||
|
@ -115,9 +112,9 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
notifyOptionsChangeForKind(kind);
|
notifyOptionsChangeForKind(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProfileInfoProvider getDiscoveredInfoProvider(){
|
// private ProfileInfoProvider getDiscoveredInfoProvider(){
|
||||||
return fDiscoveredInfo;
|
// return fDiscoveredInfo;
|
||||||
}
|
// }
|
||||||
/*
|
/*
|
||||||
private String getOptionValueFromEntry(ICLanguageSettingEntry entry){
|
private String getOptionValueFromEntry(ICLanguageSettingEntry entry){
|
||||||
String optValue = entry.getName();
|
String optValue = entry.getName();
|
||||||
|
@ -138,27 +135,27 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
|
|
||||||
if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) {
|
if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_PATH);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
} else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) {
|
} else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_FILE);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_FILE);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
} else if((kinds & ICLanguageSettingEntry.MACRO) != 0) {
|
} else if((kinds & ICLanguageSettingEntry.MACRO) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
} else if((kinds & ICLanguageSettingEntry.MACRO_FILE) != 0) {
|
} else if((kinds & ICLanguageSettingEntry.MACRO_FILE) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO_FILE);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO_FILE);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
} else if((kinds & ICLanguageSettingEntry.LIBRARY_PATH) != 0) {
|
} else if((kinds & ICLanguageSettingEntry.LIBRARY_PATH) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_PATH);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_PATH);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
} else if((kinds & ICLanguageSettingEntry.LIBRARY_FILE) != 0) {
|
} else if((kinds & ICLanguageSettingEntry.LIBRARY_FILE) != 0) {
|
||||||
EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_FILE);
|
BuildEntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_FILE);
|
||||||
if(storage != null)
|
if(storage != null)
|
||||||
storage.getEntries(list);
|
storage.getEntries(list);
|
||||||
}
|
}
|
||||||
|
@ -180,124 +177,7 @@ public class BuildLanguageData extends CLanguageData {
|
||||||
public String[] getSourceExtensions() {
|
public String[] getSourceExtensions() {
|
||||||
return fInputType != null ? fInputType.getSourceExtensions(fTool) : fTool.getPrimaryInputExtensions();
|
return fInputType != null ? fInputType.getSourceExtensions(fTool) : fTool.getPrimaryInputExtensions();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
private List getUserEntryValues(int kind){
|
|
||||||
IOption options[] = getOptionsForKind(kind);
|
|
||||||
List valueList = new ArrayList();
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
IOption option = options[i];
|
|
||||||
List value = (List)option.getValue();
|
|
||||||
valueList.addAll(value);
|
|
||||||
}
|
|
||||||
return valueList;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
DiscoveredEntry[] getDiscoveredEntryValues(int kind){
|
|
||||||
return getDiscoveredInfoProvider().getEntryValues(kind);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
private List addLanguageEntries(int kind, List list){
|
|
||||||
ICLanguageSettingEntry entries[] = getLanguageEntries(kind);
|
|
||||||
for(int i = 0; i < entries.length; i++){
|
|
||||||
list.add(entries[i]);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICLanguageSettingEntry[] getLanguageEntries(int kind){
|
|
||||||
Integer iKind = new Integer(kind);
|
|
||||||
ICLanguageSettingEntry[] entries = (ICLanguageSettingEntry[])fKindToEntryArrayMap.get(iKind);
|
|
||||||
if(entries == null){
|
|
||||||
entries = calculateLanguageEntries(kind);
|
|
||||||
fKindToEntryArrayMap.put(iKind, entries);
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICLanguageSettingEntry[] calculateLanguageEntries(int kind){
|
|
||||||
List discoveredList = fDiscoveredInfo.getEntryValues(kind);
|
|
||||||
List optionValueList = getUserEntryValues(kind);
|
|
||||||
List entryList = new ArrayList();
|
|
||||||
if(discoveredList != null && optionValueList != null){
|
|
||||||
Set set = new HashSet();
|
|
||||||
if(optionValueList != null)
|
|
||||||
processValues(kind, optionValueList, false, entryList, set);
|
|
||||||
if(discoveredList != null)
|
|
||||||
processValues(kind, discoveredList, true, entryList, set);
|
|
||||||
}
|
|
||||||
return (ICLanguageSettingEntry[])entryList.toArray(new ICLanguageSettingEntry[entryList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List processValues(int kind, List valuesList, boolean discovered, List entriesList, Set processedValuesSet){
|
|
||||||
for(Iterator iter = valuesList.iterator(); iter.hasNext();){
|
|
||||||
String value = (String)iter.next();
|
|
||||||
if(processedValuesSet.add(value)){
|
|
||||||
ICLanguageSettingEntry entry = createEntry(kind, value, discovered);
|
|
||||||
if(entry != null)
|
|
||||||
entriesList.add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entriesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICLanguageSettingEntry createEntry(int kind, String value, boolean discovered){
|
|
||||||
ICLanguageSettingEntry entry = null;
|
|
||||||
switch (kind){
|
|
||||||
case ICLanguageSettingEntry.INCLUDE_PATH:
|
|
||||||
entry = new CIncludePathEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.MACRO:
|
|
||||||
int index = value.indexOf('=');
|
|
||||||
String macroName;
|
|
||||||
String macroValue;
|
|
||||||
if(index > 0){
|
|
||||||
macroName = value.substring(index);
|
|
||||||
macroValue = value.substring(index + 1, value.length());
|
|
||||||
} else {
|
|
||||||
macroName = value;
|
|
||||||
macroValue = EMPTY_STRING;
|
|
||||||
}
|
|
||||||
entry = new CMacroEntry(macroName, macroValue, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.INCLUDE_FILE:
|
|
||||||
entry = new CIncludeFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.MACRO_FILE:
|
|
||||||
entry = new CMacroFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.LIBRARY_PATH:
|
|
||||||
entry = new CLibraryPathEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.LIBRARY_FILE:
|
|
||||||
entry = new CLibraryFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String optionPathToEntryValue(String path, boolean discovered) {
|
|
||||||
//TODO:
|
|
||||||
String result = path;
|
|
||||||
if (path != null) {
|
|
||||||
IOptionPathConverter optionPathConverter = fTool.getOptionPathConverter();
|
|
||||||
if (null!=optionPathConverter) {
|
|
||||||
IPath platformPath = optionPathConverter.convertToPlatformLocation(path, null, null);
|
|
||||||
if(platformPath != null)
|
|
||||||
result = platformPath.toString();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String toEntryPathValue(String path, boolean discovered){
|
|
||||||
//TODO:
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public int getSupportedEntryKinds() {
|
public int getSupportedEntryKinds() {
|
||||||
KindBasedStore store = getKindToOptionArrayStore();
|
KindBasedStore store = getKindToOptionArrayStore();
|
||||||
IKindBasedInfo infos[] = store.getContents();
|
IKindBasedInfo infos[] = store.getContents();
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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 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){
|
|
||||||
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;
|
|
||||||
fIsDiscovered = discovered;
|
|
||||||
fOption = option;
|
|
||||||
fPosition = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntryInfo(ICLanguageSettingEntry entry, boolean discovered, String envVarName, int position){
|
|
||||||
fEntry = entry;
|
|
||||||
fIsDiscovered = discovered;
|
|
||||||
fEnvVarName = envVarName;
|
|
||||||
fPosition = position;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/* public void setOptionInfo(IOption option, int pos){
|
|
||||||
fOption = option;
|
|
||||||
fPosition = pos;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public void makeOverridden(boolean overrridden){
|
|
||||||
/* fOption = null;
|
|
||||||
fEnvVarName = null;
|
|
||||||
fPosition = 0;
|
|
||||||
*/
|
|
||||||
fIsOverRidden = overrridden;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public void setEnvironmentInfo(String envVarName, int pos){
|
|
||||||
fEnvVarName = envVarName;
|
|
||||||
fPosition = pos;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public ICLanguageSettingEntry getEntry(){
|
|
||||||
return fEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDiscovered(){
|
|
||||||
return fIsDiscovered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOverridden(){
|
|
||||||
// return fOption != null || fEnvVarName != null;
|
|
||||||
return fIsOverRidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUndefined(){
|
|
||||||
//TODO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public IOption getOption(){
|
|
||||||
return fOption;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/* public String getEnvVarName(){
|
|
||||||
return fEnvVarName;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/* public int getPosition(){
|
|
||||||
return fPosition;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
|
||||||
import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
|
|
||||||
|
|
||||||
public class EntryListMap {
|
|
||||||
private HashMap fMap = new HashMap();
|
|
||||||
private ArrayList fList = new ArrayList();
|
|
||||||
|
|
||||||
public EntryInfo getEntryInfo(ICLanguageSettingEntry entry){
|
|
||||||
return (EntryInfo)fMap.get(new EntryNameKey(entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEntryInfo(EntryInfo info){
|
|
||||||
EntryNameKey key = info.getNameKey();
|
|
||||||
EntryInfo old = (EntryInfo)fMap.remove(key);
|
|
||||||
if(old != null)
|
|
||||||
fList.remove(old);
|
|
||||||
fMap.put(key, info);
|
|
||||||
fList.add(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map getEntryInfoMap(){
|
|
||||||
return (Map)fMap.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getEntryInfoList(){
|
|
||||||
return (List)fList.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EntryIterator implements Iterator{
|
|
||||||
Iterator fIter;
|
|
||||||
Object fCurrent;
|
|
||||||
EntryIterator (Iterator iter){
|
|
||||||
fIter = iter;
|
|
||||||
}
|
|
||||||
public boolean hasNext() {
|
|
||||||
return fIter.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object next() {
|
|
||||||
return fCurrent = fIter.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove() {
|
|
||||||
fMap.remove(((EntryInfo)fCurrent).getNameKey());
|
|
||||||
fIter.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator getIterator(){
|
|
||||||
return new EntryIterator(fList.iterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntryInfo[] getEntries(){
|
|
||||||
return (EntryInfo[])fList.toArray(new EntryInfo[fList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(){
|
|
||||||
fMap.clear();
|
|
||||||
fList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize(){
|
|
||||||
return fList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntryInfo getEntryInfo(int i){
|
|
||||||
return (EntryInfo)fList.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,501 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
|
|
||||||
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
|
||||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
|
||||||
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
|
||||||
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.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.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 SettingsSet fSettings;
|
|
||||||
// private EntryListMap fDiscoveredEntries = new EntryListMap();
|
|
||||||
// private EntryListMap fUserEntries = new EntryListMap();
|
|
||||||
// private ICLanguageSettingEntry fEntries[];
|
|
||||||
private BuildLanguageData fLangData;
|
|
||||||
// private boolean fCacheInited;
|
|
||||||
// private boolean fUserValuesInited;
|
|
||||||
|
|
||||||
private static final String EMPTY_STRING = new String();
|
|
||||||
|
|
||||||
public EntryStorage(int kind, BuildLanguageData lData){
|
|
||||||
fKind = kind;
|
|
||||||
fLangData = lData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKind(){
|
|
||||||
return fKind;
|
|
||||||
}
|
|
||||||
|
|
||||||
void optionsChanged(){
|
|
||||||
// fUserValuesInited = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getEntries(List list){
|
|
||||||
SettingsSet settings = initCache();
|
|
||||||
if(list == null)
|
|
||||||
list = new ArrayList();
|
|
||||||
|
|
||||||
ICLanguageSettingEntry entries[] = settings.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());
|
|
||||||
// }
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetDefaults(){
|
|
||||||
resetCache();
|
|
||||||
|
|
||||||
IOption options[] = fLangData.getOptionsForKind(fKind);
|
|
||||||
ITool tool = fLangData.getTool();
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
IOption option = options[i];
|
|
||||||
if(option.getParent() == tool){
|
|
||||||
tool.removeOption(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options = fLangData.getUndefOptionsForKind(fKind);
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
IOption option = options[i];
|
|
||||||
if(option.getParent() == tool){
|
|
||||||
tool.removeOption(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetCache(){
|
|
||||||
// fCacheInited = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntries(ICLanguageSettingEntry entries[]){
|
|
||||||
if(entries == null){
|
|
||||||
resetDefaults();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SettingsSet settings = initCache();
|
|
||||||
|
|
||||||
settings.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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
SettingLevel level = settings.getLevels()[0];
|
|
||||||
IOption options[] = fLangData.getOptionsForKind(fKind);
|
|
||||||
if(options.length != 0){
|
|
||||||
ICLanguageSettingEntry usrEntries[] = level.getEntries();
|
|
||||||
IOption option = options[0];
|
|
||||||
String optValue[] = new String[usrEntries.length];
|
|
||||||
if(usrEntries.length != 0){
|
|
||||||
for(int i = 0; i < usrEntries.length; i++){
|
|
||||||
ICLanguageSettingEntry entry = usrEntries[i];
|
|
||||||
optValue[i] = entryValueToOption(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ITool tool = fLangData.getTool();
|
|
||||||
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
|
||||||
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
|
||||||
options = fLangData.getOptionsForKind(fKind);
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
if(options[i] != newOption)
|
|
||||||
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options = fLangData.getUndefOptionsForKind(fKind);
|
|
||||||
if(options.length != 0){
|
|
||||||
Set set = level.containsOverrideInfo() ? level.getOverrideSet() : null;
|
|
||||||
String[] optValue = set != null ? (String[])set.toArray(new String[set.size()]) : new String[0];
|
|
||||||
IOption option = options[0];
|
|
||||||
ITool tool = fLangData.getTool();
|
|
||||||
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
|
||||||
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
|
||||||
options = fLangData.getUndefOptionsForKind(fKind);
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
if(options[i] != newOption)
|
|
||||||
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SettingsSet initCache(){
|
|
||||||
// if(fCacheInited){
|
|
||||||
// if(!fUserValuesInited){
|
|
||||||
// for(Iterator iter = fDiscoveredEntries.getIterator(); iter.hasNext();){
|
|
||||||
// EntryInfo info = (EntryInfo)iter.next();
|
|
||||||
// info.makeOverridden(false);
|
|
||||||
// }
|
|
||||||
// initUserValues();
|
|
||||||
// fUserValuesInited = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
SettingsSet settings = createEmptySettings();
|
|
||||||
SettingLevel levels[] = settings.getLevels();
|
|
||||||
// fCacheInited = true;
|
|
||||||
DiscoveredEntry[] dEntries = fLangData.getDiscoveredEntryValues(fKind);
|
|
||||||
addEntries(levels[2], dEntries);
|
|
||||||
|
|
||||||
dEntries = getDiscoveredEnvironmentEntries();
|
|
||||||
addEntries(levels[1], dEntries);
|
|
||||||
|
|
||||||
dEntries = getUserDiscoveredEntries();
|
|
||||||
addEntries(levels[0], dEntries);
|
|
||||||
levels[0].fOverrideSet = getUserUndefinedStringSet();
|
|
||||||
|
|
||||||
settings.adjustOverrideState();
|
|
||||||
|
|
||||||
return settings;
|
|
||||||
//// 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();
|
|
||||||
|
|
||||||
boolean override = isDiscoveredEntriesOverridable();
|
|
||||||
int readOnlyFlag = override ? 0 : ICSettingEntry.READONLY;
|
|
||||||
levels[0].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
|
|
||||||
levels[0].setFlagsToSet(0);
|
|
||||||
levels[0].setReadOnly(false);
|
|
||||||
levels[0].setOverrideSupported(override);
|
|
||||||
|
|
||||||
levels[1].setFlagsToClear(ICSettingEntry.BUILTIN);
|
|
||||||
levels[1].setFlagsToSet(readOnlyFlag | ICSettingEntry.RESOLVED);
|
|
||||||
levels[1].setReadOnly(true);
|
|
||||||
levels[1].setOverrideSupported(false);
|
|
||||||
|
|
||||||
levels[2].setFlagsToClear(0);
|
|
||||||
levels[2].setFlagsToSet(readOnlyFlag | ICSettingEntry.BUILTIN | ICSettingEntry.RESOLVED);
|
|
||||||
levels[2].setReadOnly(true);
|
|
||||||
levels[2].setOverrideSupported(false);
|
|
||||||
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDiscoveredEntriesOverridable(){
|
|
||||||
// if(!needUndef())
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
return fLangData.getUndefOptionsForKind(fKind).length != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private boolean needUndef(){
|
|
||||||
// return fKind != ICLanguageSettingEntry.MACRO;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 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 HashSet getUserUndefinedStringSet(){
|
|
||||||
HashSet set = null;
|
|
||||||
IOption options[] = fLangData.getUndefOptionsForKind(fKind);
|
|
||||||
if(options.length > 0){
|
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
IOption option = options[i];
|
|
||||||
List list = (List)option.getValue();
|
|
||||||
if(list.size() != 0){
|
|
||||||
if(set == null)
|
|
||||||
set = new HashSet();
|
|
||||||
set.addAll(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
private DiscoveredEntry[] getUserDiscoveredEntries(){
|
|
||||||
IOption options[] = fLangData.getOptionsForKind(fKind);
|
|
||||||
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();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
entryList.add(discoveredEntryFromString(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (DiscoveredEntry[])entryList.toArray(new DiscoveredEntry[entryList.size()]);
|
|
||||||
}
|
|
||||||
return new DiscoveredEntry[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private DiscoveredEntry discoveredEntryFromString(String str){
|
|
||||||
if(fKind == ICLanguageSettingEntry.MACRO){
|
|
||||||
String nv[] = macroNameValueFromValue(str);
|
|
||||||
return new DiscoveredEntry(nv[0], nv[1]);
|
|
||||||
}
|
|
||||||
return new DiscoveredEntry(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* private List processValues(List valuesList, boolean discovered, List entriesList){
|
|
||||||
for(Iterator iter = valuesList.iterator(); iter.hasNext();){
|
|
||||||
String value = (String)iter.next();
|
|
||||||
ICLanguageSettingEntry entry = createEntry(value, discovered);
|
|
||||||
if(entry != null)
|
|
||||||
entriesList.add(entry);
|
|
||||||
}
|
|
||||||
return entriesList;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private ICLanguageSettingEntry createEntry(DiscoveredEntry dEntry/*, boolean discovered, boolean readOnly*/){
|
|
||||||
ICLanguageSettingEntry entry = null;
|
|
||||||
int flags = 0;//discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0;
|
|
||||||
Object v[];
|
|
||||||
String value = dEntry.getValue();
|
|
||||||
String name = dEntry.getName();
|
|
||||||
switch (fKind){
|
|
||||||
case ICLanguageSettingEntry.INCLUDE_PATH:
|
|
||||||
v = optionPathValueToEntry(value);
|
|
||||||
value = (String)v[0];
|
|
||||||
if(((Boolean)v[1]).booleanValue())
|
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
|
||||||
entry = new CIncludePathEntry(value, flags);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.MACRO:
|
|
||||||
//String nv[] = macroNameValueFromValue(value);
|
|
||||||
|
|
||||||
entry = new CMacroEntry(name, value, flags);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.INCLUDE_FILE:
|
|
||||||
v = optionPathValueToEntry(value);
|
|
||||||
value = (String)v[0];
|
|
||||||
if(((Boolean)v[1]).booleanValue())
|
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
|
||||||
entry = new CIncludeFileEntry(value, flags);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.MACRO_FILE:
|
|
||||||
v = optionPathValueToEntry(value);
|
|
||||||
value = (String)v[0];
|
|
||||||
if(((Boolean)v[1]).booleanValue())
|
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
|
||||||
entry = new CMacroFileEntry(value, flags);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.LIBRARY_PATH:
|
|
||||||
v = optionPathValueToEntry(value);
|
|
||||||
value = (String)v[0];
|
|
||||||
if(((Boolean)v[1]).booleanValue())
|
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
|
||||||
entry = new CLibraryPathEntry(value, flags);
|
|
||||||
break;
|
|
||||||
case ICLanguageSettingEntry.LIBRARY_FILE:
|
|
||||||
v = optionPathValueToEntry(value);
|
|
||||||
value = (String)v[0];
|
|
||||||
if(((Boolean)v[1]).booleanValue())
|
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
|
||||||
entry = new CLibraryFileEntry(value, flags);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, boolean discovered){
|
|
||||||
//ICLanguageSettingEntry entry = null;
|
|
||||||
int flags = entry.getFlags();
|
|
||||||
if(discovered)
|
|
||||||
flags |= ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY;
|
|
||||||
|
|
||||||
switch (fKind){
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] macroNameValueFromValue(String value){
|
|
||||||
String nv[] = new String[2];
|
|
||||||
int index = value.indexOf('=');
|
|
||||||
if(index > 0){
|
|
||||||
nv[0] = value.substring(0, index);
|
|
||||||
nv[1] = value.substring(index + 1);
|
|
||||||
} else {
|
|
||||||
nv[0] = value;
|
|
||||||
nv[1] = EMPTY_STRING;
|
|
||||||
}
|
|
||||||
return nv;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String nameFromValue(String value){
|
|
||||||
if(fKind != ICLanguageSettingEntry.MACRO){
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return macroNameValueFromValue(value)[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private String entryValueToOption(ICLanguageSettingEntry entry){
|
|
||||||
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
|
|
||||||
return new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
|
||||||
} else if(entry instanceof ICLanguageSettingPathEntry){
|
|
||||||
ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
|
|
||||||
if(pathEntry.isValueWorkspacePath()){
|
|
||||||
return ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object[] optionPathValueToEntry(String value){
|
|
||||||
String wspPath = ManagedBuildManager.locationToFullPath(value);
|
|
||||||
if(wspPath != null)
|
|
||||||
return new Object[]{wspPath, Boolean.valueOf(true)};
|
|
||||||
return new Object[]{value, Boolean.valueOf(false)};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,8 +17,8 @@ import java.util.Map;
|
||||||
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
|
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -27,228 +27,116 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class ProfileInfoProvider {
|
public class ProfileInfoProvider {
|
||||||
static class DiscoveredEntry {
|
private static ProfileInfoProvider fInstance;
|
||||||
private String fName;
|
// private BuildLanguageData fLlanguageData;
|
||||||
private String fValue;
|
// private IProject fProject;
|
||||||
|
// private CfgInfoContext fContext;
|
||||||
public DiscoveredEntry(IPath path){
|
|
||||||
fName = path.toString();
|
|
||||||
fValue = fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiscoveredEntry(String name){
|
|
||||||
fName = name;
|
|
||||||
fValue = fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiscoveredEntry(String name, String value){
|
|
||||||
fName = name;
|
|
||||||
fValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName(){
|
|
||||||
return fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue(){
|
|
||||||
return fValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BuildLanguageData fLlanguageData;
|
|
||||||
// private String fProfileId;
|
|
||||||
// private IScannerInfoCollector fCollector;
|
|
||||||
// private boolean fDataCollected;
|
|
||||||
// private IProject fProject;
|
|
||||||
// private IResource fResource;
|
|
||||||
// private IPath fRcPath;
|
|
||||||
private IProject fProject;
|
|
||||||
private CfgInfoContext fContext;
|
|
||||||
private CfgDiscoveredPathManager fMngr;
|
private CfgDiscoveredPathManager fMngr;
|
||||||
|
|
||||||
public ProfileInfoProvider(BuildLanguageData lData){
|
private ProfileInfoProvider(){
|
||||||
fLlanguageData = lData;
|
// fLlanguageData = lData;
|
||||||
IResourceInfo rcInfo = lData.getTool().getParentResourceInfo();
|
// IResourceInfo rcInfo = lData.getTool().getParentResourceInfo();
|
||||||
fContext = new CfgInfoContext(rcInfo, lData.getTool(), lData.getInputType());
|
// fContext = new CfgInfoContext(rcInfo, lData.getTool(), lData.getInputType());
|
||||||
fMngr = CfgDiscoveredPathManager.getInstance();
|
fMngr = CfgDiscoveredPathManager.getInstance();
|
||||||
IResource rc = rcInfo.getParent().getOwner();
|
// IResource rc = rcInfo.getParent().getOwner();
|
||||||
fProject = rc != null ? rc.getProject() : null;
|
// fProject = rc != null ? rc.getProject() : null;
|
||||||
|
|
||||||
// clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkUpdateInputType(IInputType inType){
|
public static ProfileInfoProvider getInstance(){
|
||||||
if(inType != fContext.getInputType()){
|
if(fInstance == null)
|
||||||
// IResourceInfo rcInfo = fContext.getResourceInfo();
|
fInstance = new ProfileInfoProvider();
|
||||||
// if(rcInfo == null){
|
return fInstance;
|
||||||
// rcInfo = fContext.getConfiguration().getRootFolderInfo();
|
|
||||||
// }
|
|
||||||
fContext = new CfgInfoContext(fContext.getResourceInfo(), fContext.getTool(), inType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void clear(){
|
// void checkUpdateInputType(IInputType inType){
|
||||||
// fDataCollected = false;
|
// if(inType != fContext.getInputType()){
|
||||||
// }
|
// fContext = new CfgInfoContext(fContext.getResourceInfo(), fContext.getTool(), inType);
|
||||||
//
|
|
||||||
// private void invoke(){
|
|
||||||
// if(fDataCollected)
|
|
||||||
// return;
|
|
||||||
// fDataCollected = true;
|
|
||||||
//
|
|
||||||
// fProfileId = fLlanguageData.getDiscoveryProfileId();
|
|
||||||
//
|
|
||||||
// if (fProfileId != null){
|
|
||||||
//
|
|
||||||
// SCProfileInstance profileInstance = null;
|
|
||||||
// IResourceInfo rcInfo = fLlanguageData.getTool().getParentResourceInfo();
|
|
||||||
// fProject = rcInfo.getParent().getOwner().getProject();
|
|
||||||
// fRcPath = rcInfo.getPath();
|
|
||||||
// fResource = fProject.findMember(fRcPath);
|
|
||||||
//
|
|
||||||
// if(fResource != null){
|
|
||||||
// //FIXME:
|
|
||||||
// InfoContext context = ScannerConfigUtil.createContextForProject(fProject);
|
|
||||||
// profileInstance = ScannerConfigProfileManager.getInstance().
|
|
||||||
// getSCProfileInstance(fProject, context, fProfileId);
|
|
||||||
// fCollector = profileInstance.createScannerInfoCollector();
|
|
||||||
//
|
|
||||||
// // synchronized(this) {
|
|
||||||
// if (fCollector != null) {
|
|
||||||
// if(fCollector instanceof IManagedScannerInfoCollector)
|
|
||||||
// ((IManagedScannerInfoCollector)fCollector).setProject(fProject);
|
|
||||||
// calculateEntriesDynamically(fProject, profileInstance, fCollector);
|
|
||||||
// }
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
public DiscoveredEntry[] getEntryValues(int kind){
|
public ICLanguageSettingEntry[] getEntryValues(BuildLanguageData lData, int kind, int flags){
|
||||||
// ScannerInfoTypes type = kindToType(kind);
|
IResourceInfo rcInfo = lData.getTool().getParentResourceInfo();
|
||||||
// if(type != null){
|
IResource rc = rcInfo.getParent().getOwner();
|
||||||
if(fProject != null){
|
IProject project = rc != null ? rc.getProject() : null;
|
||||||
|
|
||||||
|
if(project != null){
|
||||||
try {
|
try {
|
||||||
PathInfo info = fMngr.getDiscoveredInfo(fProject, fContext);
|
CfgInfoContext context = new CfgInfoContext(rcInfo, lData.getTool(), lData.getInputType());
|
||||||
|
PathInfo info = fMngr.getDiscoveredInfo(project, context);
|
||||||
if(info != null){
|
if(info != null){
|
||||||
return entriesForKind(info, kind);
|
return entriesForKind(kind, flags, info);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
ManagedBuilderCorePlugin.log(e);
|
ManagedBuilderCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
return new ICLanguageSettingEntry[0];
|
||||||
return new DiscoveredEntry[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private ScannerInfoTypes kindToType(int kind){
|
private ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){
|
||||||
// switch (kind) {
|
|
||||||
// case ICLanguageSettingEntry.INCLUDE_PATH:
|
|
||||||
// return ScannerInfoTypes.INCLUDE_PATHS;
|
|
||||||
// case ICLanguageSettingEntry.MACRO:
|
|
||||||
// return ScannerInfoTypes.SYMBOL_DEFINITIONS;
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private DiscoveredEntry[] entriesForKind(PathInfo info, int kind){
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case ICLanguageSettingEntry.INCLUDE_PATH:
|
case ICLanguageSettingEntry.INCLUDE_PATH:
|
||||||
DiscoveredEntry[] incPaths = calculateEntries(info.getIncludePaths());
|
ICLanguageSettingEntry[] incPaths = calculateEntries(kind, flags, info.getIncludePaths());
|
||||||
IPath[] quotedPaths = info.getQuoteIncludePaths();
|
IPath[] quotedPaths = info.getQuoteIncludePaths();
|
||||||
if(quotedPaths.length != 0){
|
if(quotedPaths.length != 0){
|
||||||
if(incPaths.length != 0){
|
if(incPaths.length != 0){
|
||||||
DiscoveredEntry quotedEntries[] = calculateEntries(quotedPaths);
|
ICLanguageSettingEntry quotedEntries[] = calculateEntries(kind, flags, quotedPaths);
|
||||||
DiscoveredEntry[] tmp = new DiscoveredEntry[incPaths.length + quotedEntries.length];
|
ICLanguageSettingEntry[] tmp = new ICLanguageSettingEntry[incPaths.length + quotedEntries.length];
|
||||||
System.arraycopy(incPaths, 0, tmp, 0, incPaths.length);
|
System.arraycopy(incPaths, 0, tmp, 0, incPaths.length);
|
||||||
System.arraycopy(quotedEntries, 0, tmp, incPaths.length, quotedEntries.length);
|
System.arraycopy(quotedEntries, 0, tmp, incPaths.length, quotedEntries.length);
|
||||||
incPaths = tmp;
|
incPaths = tmp;
|
||||||
} else {
|
} else {
|
||||||
incPaths = calculateEntries(quotedPaths);
|
incPaths = calculateEntries(kind, flags, quotedPaths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return incPaths;
|
return incPaths;
|
||||||
case ICLanguageSettingEntry.MACRO:
|
case ICLanguageSettingEntry.MACRO:
|
||||||
return calculateEntries(info.getSymbols());
|
return calculateEntries(kind, flags, info.getSymbols());
|
||||||
case ICLanguageSettingEntry.MACRO_FILE:
|
case ICLanguageSettingEntry.MACRO_FILE:
|
||||||
return calculateEntries(info.getMacroFiles());
|
return calculateEntries(kind, flags, info.getMacroFiles());
|
||||||
case ICLanguageSettingEntry.INCLUDE_FILE:
|
case ICLanguageSettingEntry.INCLUDE_FILE:
|
||||||
return calculateEntries(info.getIncludeFiles());
|
return calculateEntries(kind, flags, info.getIncludeFiles());
|
||||||
}
|
}
|
||||||
return new DiscoveredEntry[0];
|
return new ICLanguageSettingEntry[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveredEntry[] calculateEntries(Map map){
|
private ICLanguageSettingEntry[] calculateEntries(int kind, int flags, Map map){
|
||||||
DiscoveredEntry entries[] = new DiscoveredEntry[map.size()];
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[map.size()];
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
|
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
String name = (String)entry.getKey();
|
String name = (String)entry.getKey();
|
||||||
String value = (String)entry.getValue();
|
String value = (String)entry.getValue();
|
||||||
entries[num++] = new DiscoveredEntry(name, value);
|
entries[num++] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, value, null, flags);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveredEntry[] calculateEntries(String[] values){
|
private ICLanguageSettingEntry[] calculateEntries(int kind, int flags, String[] values){
|
||||||
DiscoveredEntry entries[] = new DiscoveredEntry[values.length];
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[values.length];
|
||||||
for(int i = 0; i < values.length; i++){
|
for(int i = 0; i < values.length; i++){
|
||||||
String name = values[i];
|
String name = values[i];
|
||||||
entries[i] = new DiscoveredEntry(name);
|
entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveredEntry[] calculateEntries(IPath[] values){
|
private ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values){
|
||||||
DiscoveredEntry entries[] = new DiscoveredEntry[values.length];
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[values.length];
|
||||||
for(int i = 0; i < values.length; i++){
|
for(int i = 0; i < values.length; i++){
|
||||||
String name = values[i].toString();
|
String name = values[i].toString();
|
||||||
entries[i] = new DiscoveredEntry(name);
|
entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveredEntry[] calculateEntries(List list){
|
private ICLanguageSettingEntry[] calculateEntries(int kind, int flags, List list){
|
||||||
DiscoveredEntry entries[] = new DiscoveredEntry[list.size()];
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[list.size()];
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for(Iterator iter = list.iterator(); iter.hasNext();){
|
for(Iterator iter = list.iterator(); iter.hasNext();){
|
||||||
String name = (String)iter.next();
|
String name = (String)iter.next();
|
||||||
entries[num++] = new DiscoveredEntry(name);
|
entries[num++] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// private void calculateEntriesDynamically(final IProject project,
|
|
||||||
// SCProfileInstance profileInstance,
|
|
||||||
// final IScannerInfoCollector collector) {
|
|
||||||
// // TODO Get the provider from the toolchain specification
|
|
||||||
//
|
|
||||||
// final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
|
|
||||||
// createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
|
|
||||||
// profileInstance.getProfile().getId(), false);
|
|
||||||
// List providerIds = buildInfo.getProviderIdList();
|
|
||||||
// for (Iterator i = providerIds.iterator(); i.hasNext(); ) {
|
|
||||||
// final String providerId = (String) i.next();
|
|
||||||
// final IExternalScannerInfoProvider esiProvider = profileInstance.createExternalScannerInfoProvider(providerId);
|
|
||||||
//
|
|
||||||
// // Set the arguments for the provider
|
|
||||||
//
|
|
||||||
// ISafeRunnable runnable = new ISafeRunnable() {
|
|
||||||
// public void run() {
|
|
||||||
// IProgressMonitor monitor = new NullProgressMonitor();
|
|
||||||
// esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void handleException(Throwable exception) {
|
|
||||||
// if (exception instanceof OperationCanceledException) {
|
|
||||||
// throw (OperationCanceledException) exception;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// Platform.run(runnable);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,274 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.Iterator;
|
|
||||||
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 boolean fIsOverrideSupported;
|
|
||||||
private EntryListMap fEntries;
|
|
||||||
HashSet fOverrideSet;
|
|
||||||
|
|
||||||
private SettingLevel(){
|
|
||||||
fEntries = new EntryListMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReadOnly(){
|
|
||||||
return fIsReadOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadOnly(boolean readOnly){
|
|
||||||
fIsReadOnly = readOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOverrideSupported(){
|
|
||||||
return fIsOverrideSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOverrideSupported(boolean supported){
|
|
||||||
fIsOverrideSupported = supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlagsToSet(int flags){
|
|
||||||
fFlagsToSet = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsOverrideInfo(){
|
|
||||||
return fOverrideSet != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlagsToClear(int flags){
|
|
||||||
fFlagsToClear = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFlagsToSet(){
|
|
||||||
return fFlagsToSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFlagsToClear(){
|
|
||||||
return fFlagsToClear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set getOverrideSet(){
|
|
||||||
if(fOverrideSet != null)
|
|
||||||
return (HashSet)fOverrideSet.clone();
|
|
||||||
return new HashSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEntry(ICLanguageSettingEntry entry){
|
|
||||||
entry = CDataUtil.createEntry(entry, fFlagsToSet, fFlagsToClear);
|
|
||||||
fEntries.addEntryInfo(new EntryInfo(entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOverrideName(String name){
|
|
||||||
if(fOverrideSet == null)
|
|
||||||
fOverrideSet = new HashSet();
|
|
||||||
|
|
||||||
fOverrideSet.add(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeOverrideName(String name){
|
|
||||||
if(fOverrideSet == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fOverrideSet.remove(name);
|
|
||||||
|
|
||||||
if(fOverrideSet.size() == 0)
|
|
||||||
fOverrideSet = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(){
|
|
||||||
fEntries.clear();
|
|
||||||
fOverrideSet = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(){
|
|
||||||
int dNum = getDefaultLevelNum();
|
|
||||||
SettingLevel dLevel = fLevels[dNum];
|
|
||||||
|
|
||||||
|
|
||||||
Set set = dLevel.isOverrideSupported() ? dLevel.getOverrideSet() : 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.getEntry().getName())){
|
|
||||||
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){
|
|
||||||
HashMap map = getEntryLevelMap(WRITABLE | READ_ONLY);
|
|
||||||
Map mapCopy = (HashMap)map.clone();
|
|
||||||
|
|
||||||
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);
|
|
||||||
Object[] o = (Object[])map.get(key);
|
|
||||||
|
|
||||||
if(o != null){
|
|
||||||
mapCopy.remove(key);
|
|
||||||
levelInteger = (Integer)o[0];
|
|
||||||
} else {
|
|
||||||
levelInteger = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
levelNum = levelInteger != null ? levelInteger.intValue() : defaultLevel;
|
|
||||||
level = fLevels[levelNum];
|
|
||||||
if(!level.isReadOnly())
|
|
||||||
level.addEntry(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
level = fLevels[defaultLevel];
|
|
||||||
if(level.isOverrideSupported() && !mapCopy.isEmpty()){
|
|
||||||
String str;
|
|
||||||
for(Iterator iter = mapCopy.keySet().iterator(); iter.hasNext();){
|
|
||||||
str = ((EntryNameKey)iter.next()).getEntry().getName();
|
|
||||||
if(str != null)
|
|
||||||
level.addOverrideName(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
adjustOverrideState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap getEntryLevelMap(int types){
|
|
||||||
HashMap 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 Object[]{new Integer(l), info.getEntry()});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.core.settings.model.util;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
|
||||||
|
|
||||||
public class EntryInfo {
|
|
||||||
private ICLanguageSettingEntry fEntry;
|
|
||||||
private EntryNameKey fNameKey;
|
|
||||||
private boolean fIsOverRidden;
|
|
||||||
|
|
||||||
EntryInfo(ICLanguageSettingEntry entry){
|
|
||||||
fEntry = entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntryNameKey getNameKey(){
|
|
||||||
if(fNameKey == null){
|
|
||||||
fNameKey = new EntryNameKey(fEntry);
|
|
||||||
}
|
|
||||||
return fNameKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void makeOverridden(boolean overrridden){
|
|
||||||
fIsOverRidden = overrridden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICLanguageSettingEntry getEntry(){
|
|
||||||
return fEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOverridden(){
|
|
||||||
return fIsOverRidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ public class SettingsSet {
|
||||||
return fFlagsToClear;
|
return fFlagsToClear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFlags(int baseFlags){
|
||||||
|
return (baseFlags | fFlagsToSet) & (~fFlagsToClear);
|
||||||
|
}
|
||||||
|
|
||||||
public Set getOverrideSet(){
|
public Set getOverrideSet(){
|
||||||
if(fOverrideSet != null)
|
if(fOverrideSet != null)
|
||||||
return (HashSet)fOverrideSet.clone();
|
return (HashSet)fOverrideSet.clone();
|
||||||
|
@ -94,10 +98,14 @@ public class SettingsSet {
|
||||||
addEntry((ICLanguageSettingEntry)list.get(i));
|
addEntry((ICLanguageSettingEntry)list.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntry(ICLanguageSettingEntry entry){
|
public void addEntry(ICLanguageSettingEntry entry){
|
||||||
|
addEntry(entry, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntry(ICLanguageSettingEntry entry, Object customInfo){
|
||||||
entry = CDataUtil.createEntry(entry, fFlagsToSet, fFlagsToClear);
|
entry = CDataUtil.createEntry(entry, fFlagsToSet, fFlagsToClear);
|
||||||
EntryInfo info = new EntryInfo(entry);
|
EntryInfo info = new EntryInfo(entry, customInfo);
|
||||||
fEntries.put(info.getNameKey(), info);
|
fEntries.put(info.getNameKey(), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +115,16 @@ public class SettingsSet {
|
||||||
|
|
||||||
fOverrideSet.add(name);
|
fOverrideSet.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addOverrideNameSet(Set set){
|
||||||
|
if(set == null)
|
||||||
|
return;
|
||||||
|
if(fOverrideSet != null){
|
||||||
|
fOverrideSet.addAll(set);
|
||||||
|
} else if(set.size() != 0){
|
||||||
|
fOverrideSet = new HashSet(set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeOverrideName(String name){
|
public void removeOverrideName(String name){
|
||||||
if(fOverrideSet == null)
|
if(fOverrideSet == null)
|
||||||
|
@ -123,7 +141,14 @@ public class SettingsSet {
|
||||||
fOverrideSet = null;
|
fOverrideSet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntryInfo[] getInfos(){
|
public Map clearAndGetMap(){
|
||||||
|
Map map = fEntries;
|
||||||
|
fEntries = new LinkedHashMap();
|
||||||
|
fOverrideSet = null;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntryInfo[] getInfos(){
|
||||||
return (EntryInfo[])fEntries.values().toArray(new EntryInfo[fEntries.size()]);
|
return (EntryInfo[])fEntries.values().toArray(new EntryInfo[fEntries.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +172,41 @@ public class SettingsSet {
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EntryInfo {
|
||||||
|
private ICLanguageSettingEntry fEntry;
|
||||||
|
private EntryNameKey fNameKey;
|
||||||
|
private boolean fIsOverRidden;
|
||||||
|
private Object fCustomInfo;
|
||||||
|
|
||||||
|
private EntryInfo(ICLanguageSettingEntry entry, Object customInfo){
|
||||||
|
fEntry = entry;
|
||||||
|
fCustomInfo = customInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntryNameKey getNameKey(){
|
||||||
|
if(fNameKey == null){
|
||||||
|
fNameKey = new EntryNameKey(fEntry);
|
||||||
|
}
|
||||||
|
return fNameKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeOverridden(boolean overrridden){
|
||||||
|
fIsOverRidden = overrridden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICLanguageSettingEntry getEntry(){
|
||||||
|
return fEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOverridden(){
|
||||||
|
return fIsOverRidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCustomInfo(){
|
||||||
|
return fCustomInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsSet(int num){
|
public SettingsSet(int num){
|
||||||
|
@ -241,9 +300,11 @@ public class SettingsSet {
|
||||||
HashMap map = getEntryLevelMap(WRITABLE | READ_ONLY);
|
HashMap map = getEntryLevelMap(WRITABLE | READ_ONLY);
|
||||||
Map mapCopy = (HashMap)map.clone();
|
Map mapCopy = (HashMap)map.clone();
|
||||||
|
|
||||||
|
Map[] clearedInfos = new Map[fLevels.length];
|
||||||
|
|
||||||
for(int i = 0; i < fLevels.length; i++){
|
for(int i = 0; i < fLevels.length; i++){
|
||||||
if(!fLevels[i].isReadOnly()){
|
if(!fLevels[i].isReadOnly()){
|
||||||
fLevels[i].clear();
|
clearedInfos[i] = fLevels[i].clearAndGetMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,13 +330,21 @@ public class SettingsSet {
|
||||||
levelNum = levelInteger != null ? levelInteger.intValue() : writableLevel;
|
levelNum = levelInteger != null ? levelInteger.intValue() : writableLevel;
|
||||||
if(levelNum >= 0){
|
if(levelNum >= 0){
|
||||||
level = fLevels[levelNum];
|
level = fLevels[levelNum];
|
||||||
if(!level.isReadOnly())
|
if(!level.isReadOnly()){
|
||||||
level.addEntry(entry);
|
Map clearedInfo = clearedInfos[levelNum];
|
||||||
|
Object customInfo = null;
|
||||||
|
if(clearedInfo != null){
|
||||||
|
EntryInfo info = (EntryInfo)clearedInfo.get(key);
|
||||||
|
if(info != null && entry.equalsByContents(info.getEntry()))
|
||||||
|
customInfo = info.getCustomInfo();
|
||||||
|
}
|
||||||
|
level.addEntry(entry, customInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int overrideLevel = getOverrideLevelNum();
|
int overrideLevel = getOverrideLevelNum();
|
||||||
if(overrideLevel > 0){
|
if(overrideLevel >= 0){
|
||||||
level = fLevels[overrideLevel];
|
level = fLevels[overrideLevel];
|
||||||
if(level.isOverrideSupported() && !mapCopy.isEmpty()){
|
if(level.isOverrideSupported() && !mapCopy.isEmpty()){
|
||||||
String str;
|
String str;
|
||||||
|
|
Loading…
Add table
Reference in a new issue