mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 03:05:39 +02:00
cleanup only: generics, loops to enhanced, spaces
This commit is contained in:
parent
f953d3feb9
commit
96da536541
1 changed files with 124 additions and 133 deletions
|
@ -62,9 +62,9 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
private ICLanguageSettingEntry fEntry;
|
private ICLanguageSettingEntry fEntry;
|
||||||
private OptionStringValue fOriginalValue;
|
private OptionStringValue fOriginalValue;
|
||||||
private OptionStringValue fBsResolvedValue;
|
private OptionStringValue fBsResolvedValue;
|
||||||
private List fSequense;
|
private List<UserEntryInfo> fSequense;
|
||||||
|
|
||||||
UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue originalValue, OptionStringValue bsResolvedValue, List sequense){
|
UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue originalValue, OptionStringValue bsResolvedValue, List<UserEntryInfo> sequense){
|
||||||
fEntry = entry;
|
fEntry = entry;
|
||||||
fOriginalValue = originalValue;
|
fOriginalValue = originalValue;
|
||||||
fBsResolvedValue = bsResolvedValue;
|
fBsResolvedValue = bsResolvedValue;
|
||||||
|
@ -73,11 +73,11 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
sequense.add(this);
|
sequense.add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmptyEntryInfo {
|
private static class EmptyEntryInfo {
|
||||||
private OptionStringValue fOriginalValue;
|
private OptionStringValue fOriginalValue;
|
||||||
private int fPosition;
|
private int fPosition;
|
||||||
|
|
||||||
EmptyEntryInfo(OptionStringValue value, int position){
|
EmptyEntryInfo(OptionStringValue value, int position){
|
||||||
fOriginalValue = value;
|
fOriginalValue = value;
|
||||||
fPosition = position;
|
fPosition = position;
|
||||||
|
@ -90,11 +90,12 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
fLangData = lData;
|
fLangData = lData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected SettingsSet createEmptySettings() {
|
protected SettingsSet createEmptySettings() {
|
||||||
SettingsSet settings = new SettingsSet(3);
|
SettingsSet settings = new SettingsSet(3);
|
||||||
SettingLevel levels[] = settings.getLevels();
|
SettingLevel levels[] = settings.getLevels();
|
||||||
|
|
||||||
boolean override = isDiscoveredEntriesOverridable();
|
boolean override = isDiscoveredEntriesOverridable();
|
||||||
int readOnlyFlag = override ? 0 : ICSettingEntry.READONLY;
|
int readOnlyFlag = override ? 0 : ICSettingEntry.READONLY;
|
||||||
levels[USER_ENTRIES_LEVEL].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
|
levels[USER_ENTRIES_LEVEL].setFlagsToClear(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
|
||||||
levels[USER_ENTRIES_LEVEL].setFlagsToSet(0);
|
levels[USER_ENTRIES_LEVEL].setFlagsToSet(0);
|
||||||
|
@ -113,7 +114,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDiscoveredEntriesOverridable(){
|
private boolean isDiscoveredEntriesOverridable(){
|
||||||
return fLangData.getUndefOptionsForKind(getKind()).length != 0;
|
return fLangData.getUndefOptionsForKind(getKind()).length != 0;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +125,8 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return fBuildDirName;
|
return fBuildDirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
|
protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
|
||||||
switch(levelNum){
|
switch(levelNum){
|
||||||
case USER_ENTRIES_LEVEL:
|
case USER_ENTRIES_LEVEL:
|
||||||
|
@ -139,39 +141,35 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
uei = new UserEntryInfo(infos[i].getEntry(), null, null, null);
|
uei = new UserEntryInfo(infos[i].getEntry(), null, null, null);
|
||||||
userInfos[i] = uei;
|
userInfos[i] = uei;
|
||||||
}
|
}
|
||||||
setUserEntries(userInfos, (List)level.getContext());
|
setUserEntries(userInfos, (List<EmptyEntryInfo>)level.getContext());
|
||||||
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
|
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreDefaults(){
|
private void restoreDefaults(){
|
||||||
IOption options[] = fLangData.getOptionsForKind(getKind());
|
|
||||||
ITool tool = fLangData.getTool();
|
ITool tool = fLangData.getTool();
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption option : fLangData.getOptionsForKind(getKind())) {
|
||||||
IOption option = options[i];
|
|
||||||
if(option.getParent() == tool){
|
if(option.getParent() == tool){
|
||||||
tool.removeOption(option);
|
tool.removeOption(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options = fLangData.getUndefOptionsForKind(getKind());
|
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
|
||||||
for(int i = 0; i < options.length; i++){
|
|
||||||
IOption option = options[i];
|
|
||||||
if(option.getParent() == tool){
|
if(option.getParent() == tool){
|
||||||
tool.removeOption(option);
|
tool.removeOption(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void putEntriesToLevel(int levelNum, SettingLevel level) {
|
protected void putEntriesToLevel(int levelNum, SettingLevel level) {
|
||||||
switch(levelNum){
|
switch(levelNum){
|
||||||
case USER_ENTRIES_LEVEL:
|
case USER_ENTRIES_LEVEL:
|
||||||
List emptyEntryInfos = new ArrayList();
|
List<EmptyEntryInfo> emptyEntryInfos = new ArrayList<EmptyEntryInfo>();
|
||||||
UserEntryInfo[] userEntries = getUserEntries(level.getFlags(0), true, emptyEntryInfos);
|
for (UserEntryInfo userEntry : getUserEntries(level.getFlags(0), true, emptyEntryInfos)) {
|
||||||
for(int i = 0; i < userEntries.length; i++){
|
level.addEntry(userEntry.fEntry, userEntry);
|
||||||
level.addEntry(userEntries[i].fEntry, userEntries[i]);
|
|
||||||
}
|
}
|
||||||
level.addOverrideNameSet(getUserUndefinedStringSet());
|
level.addOverrideNameSet(getUserUndefinedStringSet());
|
||||||
if(emptyEntryInfos.size() != 0)
|
if(emptyEntryInfos.size() != 0)
|
||||||
|
@ -187,7 +185,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICLanguageSettingEntry[] getDiscoveredEntries(int flags){
|
private ICLanguageSettingEntry[] getDiscoveredEntries(int flags){
|
||||||
ICLanguageSettingEntry[] entries = ProfileInfoProvider.getInstance().getEntryValues(fLangData, getKind(), flags);
|
ICLanguageSettingEntry[] entries = ProfileInfoProvider.getInstance().getEntryValues(fLangData, getKind(), flags);
|
||||||
if(entries == null || entries.length == 0){
|
if(entries == null || entries.length == 0){
|
||||||
|
@ -201,29 +199,28 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SupplierBasedCdtVariableSubstitutor createSubstitutor(IOption option, boolean bsVarsOnly){
|
private SupplierBasedCdtVariableSubstitutor createSubstitutor(IOption option, boolean bsVarsOnly){
|
||||||
OptionContextData ocd = new OptionContextData(option, fLangData.getTool());
|
OptionContextData ocd = new OptionContextData(option, fLangData.getTool());
|
||||||
DefaultMacroContextInfo ci = new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
DefaultMacroContextInfo ci = new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
||||||
|
|
||||||
return bsVarsOnly ?
|
return bsVarsOnly ?
|
||||||
new BuildSystemSpecificVariableSubstitutor(ci)
|
new BuildSystemSpecificVariableSubstitutor(ci)
|
||||||
: new SupplierBasedCdtVariableSubstitutor(ci, "", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
: new SupplierBasedCdtVariableSubstitutor(ci, "", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserEntryInfo[] getUserEntries(int flags, boolean usr, List emptyValuesInfos){
|
private UserEntryInfo[] getUserEntries(int flags, boolean usr, List<EmptyEntryInfo> emptyValuesInfos){
|
||||||
IOption options[] = fLangData.getOptionsForKind(getKind());
|
IOption options[] = fLangData.getOptionsForKind(getKind());
|
||||||
if(options.length > 0){
|
if(options.length > 0){
|
||||||
List entryList = new ArrayList();
|
List<UserEntryInfo> entryList = new ArrayList<UserEntryInfo>();
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
Option option = (Option)options[i];
|
Option option = (Option)opt;
|
||||||
List list = usr ? (List)option.getExactValue() : option.getExactBuiltinsList();
|
List<OptionStringValue> list = usr ? (List<OptionStringValue>)option.getExactValue() : (List<OptionStringValue>)option.getExactBuiltinsList();
|
||||||
int size = list != null ? list.size() : 0;
|
if(list != null){
|
||||||
if(size > 0){
|
|
||||||
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
|
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
|
||||||
SupplierBasedCdtVariableSubstitutor bSVarsSubst = createSubstitutor(option, true);
|
SupplierBasedCdtVariableSubstitutor bSVarsSubst = createSubstitutor(option, true);
|
||||||
for(int j = 0; j < size; j++){
|
for(int j = 0; j < list.size(); j++){
|
||||||
OptionStringValue ve = (OptionStringValue)list.get(j);
|
OptionStringValue ve = list.get(j);
|
||||||
OptionStringValue[] rVes = resolve(ve, option, bSVarsSubst);
|
OptionStringValue[] rVes = resolve(ve, option, bSVarsSubst);
|
||||||
if(rVes.length == 0){
|
if(rVes.length == 0){
|
||||||
if(emptyValuesInfos != null){
|
if(emptyValuesInfos != null){
|
||||||
|
@ -231,22 +228,21 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean isMultiple = rVes.length > 1;
|
boolean isMultiple = rVes.length > 1;
|
||||||
List sequense = isMultiple ? new ArrayList(rVes.length) : null;
|
List<UserEntryInfo> sequense = isMultiple ? new ArrayList<UserEntryInfo>(rVes.length) : null;
|
||||||
for(int k = 0; k < rVes.length; k++){
|
for (OptionStringValue rVe : rVes) {
|
||||||
OptionStringValue rVe = rVes[k];
|
ICLanguageSettingEntry entry = createUserEntry(option, rVe, flags, subst);
|
||||||
ICLanguageSettingEntry entry = createUserEntry(option, rVe, flags, subst);
|
|
||||||
entryList.add(new UserEntryInfo(entry, ve, rVe, sequense));
|
entryList.add(new UserEntryInfo(entry, ve, rVe, sequense));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UserEntryInfo[])entryList.toArray(new UserEntryInfo[entryList.size()]);
|
return entryList.toArray(new UserEntryInfo[entryList.size()]);
|
||||||
}
|
}
|
||||||
return new UserEntryInfo[0];
|
return new UserEntryInfo[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static OptionStringValue stripQuotes(OptionStringValue ov){
|
// private static OptionStringValue stripQuotes(OptionStringValue ov){
|
||||||
// String value = ov.getValue();
|
// String value = ov.getValue();
|
||||||
// value = stripQuotes(value, true);
|
// value = stripQuotes(value, true);
|
||||||
|
@ -256,40 +252,36 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
// }
|
// }
|
||||||
// return ov;
|
// return ov;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static String stripQuotes(String value, boolean nullIfNone){
|
private static String stripQuotes(String value, boolean nullIfNone){
|
||||||
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
|
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
|
||||||
return value.substring(1, value.length() - 1);
|
return value.substring(1, value.length() - 1);
|
||||||
}
|
}
|
||||||
return nullIfNone ? null : value;
|
return nullIfNone ? null : value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OptionStringValue substituteValue(OptionStringValue ov, String value){
|
private static OptionStringValue substituteValue(OptionStringValue ov, String value){
|
||||||
return new OptionStringValue(value, ov.isBuiltIn(), ov.getSourceAttachmentPath(), ov.getSourceAttachmentRootPath(), ov.getSourceAttachmentPrefixMapping());
|
return new OptionStringValue(value, ov.isBuiltIn(), ov.getSourceAttachmentPath(), ov.getSourceAttachmentRootPath(), ov.getSourceAttachmentPrefixMapping());
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashSet getUserUndefinedStringSet(){
|
private HashSet<String> getUserUndefinedStringSet(){
|
||||||
HashSet set = null;
|
HashSet<String> set = null;
|
||||||
IOption options[] = fLangData.getUndefOptionsForKind(getKind());
|
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
|
||||||
if(options.length > 0){
|
List<String> list = (List<String>)option.getValue();
|
||||||
for(int i = 0; i < options.length; i++){
|
if(list.size() != 0){
|
||||||
IOption option = options[i];
|
if(set == null)
|
||||||
List list = (List)option.getValue();
|
set = new HashSet<String>();
|
||||||
if(list.size() != 0){
|
set.addAll(list);
|
||||||
if(set == null)
|
|
||||||
set = new HashSet();
|
|
||||||
set.addAll(list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PathInfo fromBuildToProj(PathInfo info){
|
private PathInfo fromBuildToProj(PathInfo info){
|
||||||
if(info.isAbsolute())
|
if(info.isAbsolute())
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
Path path = new Path(info.getUnresolvedPath());
|
Path path = new Path(info.getUnresolvedPath());
|
||||||
String projPath;
|
String projPath;
|
||||||
if(path.segmentCount() != 0 && "..".equals(path.segment(0))){ //$NON-NLS-1$
|
if(path.segmentCount() != 0 && "..".equals(path.segment(0))){ //$NON-NLS-1$
|
||||||
|
@ -305,7 +297,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
private PathInfo fromProjToBuild(PathInfo info){
|
private PathInfo fromProjToBuild(PathInfo info){
|
||||||
if(info.isAbsolute())
|
if(info.isAbsolute())
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
Path path = new Path(info.getUnresolvedPath());
|
Path path = new Path(info.getUnresolvedPath());
|
||||||
String projPath;
|
String projPath;
|
||||||
if(path.segmentCount() != 0 && getBuildDitName().equals(path.segment(0))){
|
if(path.segmentCount() != 0 && getBuildDitName().equals(path.segment(0))){
|
||||||
|
@ -319,7 +311,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// private String[] resolve(String v, IOption option, IPath[] buildLocation){
|
// private String[] resolve(String v, IOption option, IPath[] buildLocation){
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private String[] resolve(String v, IOption option, SupplierBasedCdtVariableSubstitutor sub){
|
private String[] resolve(String v, IOption option, SupplierBasedCdtVariableSubstitutor sub){
|
||||||
|
@ -330,7 +322,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private OptionStringValue[] resolve(OptionStringValue ov, IOption option, SupplierBasedCdtVariableSubstitutor sub){
|
private OptionStringValue[] resolve(OptionStringValue ov, IOption option, SupplierBasedCdtVariableSubstitutor sub){
|
||||||
String value = ov.getValue();
|
String value = ov.getValue();
|
||||||
value = stripQuotes(value, false);
|
value = stripQuotes(value, false);
|
||||||
|
@ -346,50 +338,49 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
String paths[] = null;
|
String paths[] = null;
|
||||||
int kind = getKind();
|
int kind = getKind();
|
||||||
switch(kind){
|
switch(kind){
|
||||||
case ICLanguageSettingEntry.INCLUDE_PATH:{
|
case ICSettingEntry.INCLUDE_PATH:{
|
||||||
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ICLanguageSettingEntry.LIBRARY_PATH:{
|
case ICSettingEntry.LIBRARY_PATH:{
|
||||||
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(paths != null && paths.length != 0){
|
if(paths != null && paths.length != 0){
|
||||||
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[paths.length];
|
ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[paths.length];
|
||||||
for(int i = 0; i < paths.length; i++){
|
for(int i = 0; i < paths.length; i++){
|
||||||
entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, paths[i].toString(), null, null, flags);
|
entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, paths[i].toString(), null, null, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
return new ICLanguageSettingEntry[0];
|
return new ICLanguageSettingEntry[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags, SupplierBasedCdtVariableSubstitutor subst){
|
private ICLanguageSettingEntry createUserEntry(IOption option, OptionStringValue optionValue, int flags, SupplierBasedCdtVariableSubstitutor subst){
|
||||||
// private ICLanguageSettingEntry createUserEntry(Option option, String optionValue, int flags){
|
// private ICLanguageSettingEntry createUserEntry(Option option, String optionValue, int flags){
|
||||||
int kind = getKind();
|
int kind = getKind();
|
||||||
|
|
||||||
ICLanguageSettingEntry entry = null;
|
ICLanguageSettingEntry entry = null;
|
||||||
|
|
||||||
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;
|
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;
|
||||||
|
|
||||||
switch (kind){
|
switch (kind){
|
||||||
case ICLanguageSettingEntry.MACRO:
|
case ICSettingEntry.MACRO:
|
||||||
String nv[] = macroNameValueFromValue(optionValue.getValue());
|
String nv[] = macroNameValueFromValue(optionValue.getValue());
|
||||||
// String nv[] = macroNameValueFromValue(optionValue);
|
// String nv[] = macroNameValueFromValue(optionValue);
|
||||||
|
|
||||||
entry = new CMacroEntry(nv[0], nv[1], flags);
|
entry = new CMacroEntry(nv[0], nv[1], flags);
|
||||||
break;
|
break;
|
||||||
// case ICLanguageSettingEntry.INCLUDE_PATH:
|
// case ICSettingEntry.INCLUDE_PATH:
|
||||||
// case ICLanguageSettingEntry.INCLUDE_FILE:
|
// case ICSettingEntry.INCLUDE_FILE:
|
||||||
// case ICLanguageSettingEntry.MACRO_FILE:
|
// case ICSettingEntry.MACRO_FILE:
|
||||||
// case ICLanguageSettingEntry.LIBRARY_PATH:
|
// case ICSettingEntry.LIBRARY_PATH:
|
||||||
// case ICLanguageSettingEntry.LIBRARY_FILE:
|
case ICSettingEntry.LIBRARY_FILE:
|
||||||
case ICLanguageSettingEntry.LIBRARY_FILE:
|
|
||||||
String tmp = optionValue.getSourceAttachmentPath();
|
String tmp = optionValue.getSourceAttachmentPath();
|
||||||
if(tmp != null)
|
if(tmp != null)
|
||||||
srcPath = new Path(tmp);
|
srcPath = new Path(tmp);
|
||||||
|
@ -400,33 +391,34 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
if(tmp != null)
|
if(tmp != null)
|
||||||
srcPrefixMapping = new Path(tmp);
|
srcPrefixMapping = new Path(tmp);
|
||||||
//do not break
|
//do not break
|
||||||
|
//$FALL-THROUGH$
|
||||||
default:
|
default:
|
||||||
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
|
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
|
||||||
PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst);
|
PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst);
|
||||||
// Object[] v = optionPathValueToEntry(stripQuotes(optionValue.getValue()));
|
// Object[] v = optionPathValueToEntry(stripQuotes(optionValue.getValue()));
|
||||||
// Object[] v = optionPathValueToEntry(optionValue);
|
// Object[] v = optionPathValueToEntry(optionValue);
|
||||||
|
|
||||||
if(pInfo.isWorkspacePath()){
|
if(pInfo.isWorkspacePath()){
|
||||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||||
} else if (optionPathConverter != null){
|
} else if (optionPathConverter != null){
|
||||||
IPath path = optionPathConverter.convertToPlatformLocation(pInfo.getUnresolvedPath(), option, fLangData.getTool());
|
IPath path = optionPathConverter.convertToPlatformLocation(pInfo.getUnresolvedPath(), option, fLangData.getTool());
|
||||||
if(path != null){
|
if(path != null){
|
||||||
pInfo = new PathInfo(path.toString(), false, subst);
|
pInfo = new PathInfo(path.toString(), false, subst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo = fromBuildToProj(pInfo);
|
pInfo = fromBuildToProj(pInfo);
|
||||||
|
|
||||||
entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, pInfo.getUnresolvedPath(), null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
|
entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, pInfo.getUnresolvedPath(), null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OptionStringValue createOptionValue(IOption option, UserEntryInfo info, SupplierBasedCdtVariableSubstitutor subst){
|
private OptionStringValue createOptionValue(IOption option, UserEntryInfo info, SupplierBasedCdtVariableSubstitutor subst){
|
||||||
if(info.fOriginalValue != null)
|
if(info.fOriginalValue != null)
|
||||||
return info.fOriginalValue;
|
return info.fOriginalValue;
|
||||||
|
|
||||||
return entryValueToOption(option, info.fEntry, subst);
|
return entryValueToOption(option, info.fEntry, subst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +426,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
String optionValue = entryValueToOptionStringValue(option, entry, subst);
|
String optionValue = entryValueToOptionStringValue(option, entry, subst);
|
||||||
if(entry.getKind() == ICSettingEntry.LIBRARY_FILE){
|
if(entry.getKind() == ICSettingEntry.LIBRARY_FILE){
|
||||||
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
|
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
|
||||||
return new OptionStringValue(optionValue,
|
return new OptionStringValue(optionValue,
|
||||||
false,
|
false,
|
||||||
pathToString(libFile.getSourceAttachmentPath()),
|
pathToString(libFile.getSourceAttachmentPath()),
|
||||||
pathToString(libFile.getSourceAttachmentRootPath()),
|
pathToString(libFile.getSourceAttachmentRootPath()),
|
||||||
|
@ -442,7 +434,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return new OptionStringValue(optionValue);
|
return new OptionStringValue(optionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String pathToString(IPath path){
|
private static String pathToString(IPath path){
|
||||||
return path != null ? path.toString() : null;
|
return path != null ? path.toString() : null;
|
||||||
}
|
}
|
||||||
|
@ -450,7 +442,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){
|
private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){
|
||||||
String result;
|
String result;
|
||||||
boolean checkQuote = true;
|
boolean checkQuote = true;
|
||||||
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
|
if(entry.getKind() == ICSettingEntry.MACRO && entry.getValue().length() > 0){
|
||||||
result = new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
result = new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
||||||
} else if(entry instanceof ICLanguageSettingPathEntry){
|
} else if(entry instanceof ICLanguageSettingPathEntry){
|
||||||
IOptionPathConverter converter = fLangData.getTool().getOptionPathConverter();
|
IOptionPathConverter converter = fLangData.getTool().getOptionPathConverter();
|
||||||
|
@ -464,13 +456,13 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
} else {
|
} else {
|
||||||
result = entry.getName();
|
result = entry.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(checkQuote){
|
if(checkQuote){
|
||||||
result = doubleQuotePath(result, false);
|
result = doubleQuotePath(result, false);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doConvertToOptionValue(IOption option, ICLanguageSettingPathEntry pathEntry, SupplierBasedCdtVariableSubstitutor subst){
|
private String doConvertToOptionValue(IOption option, ICLanguageSettingPathEntry pathEntry, SupplierBasedCdtVariableSubstitutor subst){
|
||||||
boolean isWsp = pathEntry.isValueWorkspacePath();
|
boolean isWsp = pathEntry.isValueWorkspacePath();
|
||||||
PathInfo pInfo = new PathInfo(pathEntry.getName(), isWsp, subst);
|
PathInfo pInfo = new PathInfo(pathEntry.getName(), isWsp, subst);
|
||||||
|
@ -490,30 +482,30 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
} else {
|
} else {
|
||||||
result = pathEntry.getName();
|
result = pathEntry.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ManagedBuildManager.fullPathToLocation(result);
|
result = ManagedBuildManager.fullPathToLocation(result);
|
||||||
} else {
|
} else {
|
||||||
pInfo = fromProjToBuild(pInfo);
|
pInfo = fromProjToBuild(pInfo);
|
||||||
result = pInfo.getUnresolvedPath();
|
result = pInfo.getUnresolvedPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String doubleQuotePath(String pathName, boolean nullIfNone) {
|
private static String doubleQuotePath(String pathName, boolean nullIfNone) {
|
||||||
/* Trim */
|
/* Trim */
|
||||||
pathName = pathName.trim();
|
pathName = pathName.trim();
|
||||||
|
|
||||||
/* Check if path is already double-quoted */
|
/* Check if path is already double-quoted */
|
||||||
boolean bStartsWithQuote = pathName.indexOf('"') == 0;
|
boolean bStartsWithQuote = pathName.indexOf('"') == 0;
|
||||||
boolean bEndsWithQuote = pathName.lastIndexOf('"') == pathName.length() - 1;
|
boolean bEndsWithQuote = pathName.lastIndexOf('"') == pathName.length() - 1;
|
||||||
|
|
||||||
boolean quoted = false;
|
boolean quoted = false;
|
||||||
|
|
||||||
/* Check for spaces, backslashes or macros */
|
/* Check for spaces, backslashes or macros */
|
||||||
int i = pathName.indexOf(' ') + pathName.indexOf('\\') //$NON-NLS-1$ //$NON-NLS-2$
|
int i = pathName.indexOf(' ') + pathName.indexOf('\\')
|
||||||
+ pathName.indexOf("${"); //$NON-NLS-1$
|
+ pathName.indexOf("${"); //$NON-NLS-1$
|
||||||
|
|
||||||
/* If indexof didn't fail all three times, double-quote path */
|
/* If indexof didn't fail all three times, double-quote path */
|
||||||
if (i != -3) {
|
if (i != -3) {
|
||||||
if (!bStartsWithQuote){
|
if (!bStartsWithQuote){
|
||||||
|
@ -525,12 +517,12 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
quoted = true;
|
quoted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(quoted)
|
if(quoted)
|
||||||
return pathName;
|
return pathName;
|
||||||
return nullIfNone ? null : pathName;
|
return nullIfNone ? null : pathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] macroNameValueFromValue(String value){
|
public static String[] macroNameValueFromValue(String value){
|
||||||
String nv[] = new String[2];
|
String nv[] = new String[2];
|
||||||
int index = value.indexOf('=');
|
int index = value.indexOf('=');
|
||||||
|
@ -543,14 +535,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return nv;
|
return nv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static Object[] optionPathValueToEntry(String value){
|
// private static Object[] optionPathValueToEntry(String value){
|
||||||
// String wspPath = ManagedBuildManager.locationToFullPath(value);
|
// String wspPath = ManagedBuildManager.locationToFullPath(value);
|
||||||
// if(wspPath != null)
|
// if(wspPath != null)
|
||||||
// return new Object[]{wspPath, Boolean.valueOf(true)};
|
// return new Object[]{wspPath, Boolean.valueOf(true)};
|
||||||
// return new Object[]{value, Boolean.valueOf(false)};
|
// return new Object[]{value, Boolean.valueOf(false)};
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static PathInfo optionPathValueToEntry(String str, SupplierBasedCdtVariableSubstitutor subst){
|
private static PathInfo optionPathValueToEntry(String str, SupplierBasedCdtVariableSubstitutor subst){
|
||||||
String unresolvedStr = ManagedBuildManager.locationToFullPath(str);
|
String unresolvedStr = ManagedBuildManager.locationToFullPath(str);
|
||||||
boolean isWorkspacePath;
|
boolean isWorkspacePath;
|
||||||
|
@ -562,8 +554,8 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
return new PathInfo(unresolvedStr, isWorkspacePath, subst);
|
return new PathInfo(unresolvedStr, isWorkspacePath, subst);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUserEntries(UserEntryInfo[] entries, List emptyEntryInfos){
|
private void setUserEntries(UserEntryInfo[] entries, List<EmptyEntryInfo> emptyEntryInfos){
|
||||||
int kind = getKind();
|
int kind = getKind();
|
||||||
IOption options[] = fLangData.getOptionsForKind(kind);
|
IOption options[] = fLangData.getOptionsForKind(kind);
|
||||||
if(options.length != 0){
|
if(options.length != 0){
|
||||||
|
@ -571,9 +563,9 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
OptionStringValue[] optValue;
|
OptionStringValue[] optValue;
|
||||||
if(entries.length != 0){
|
if(entries.length != 0){
|
||||||
entries = combineSequenses(entries);
|
entries = combineSequenses(entries);
|
||||||
|
|
||||||
entries = addEmptyEntries(entries, emptyEntryInfos);
|
entries = addEmptyEntries(entries, emptyEntryInfos);
|
||||||
|
|
||||||
optValue = new OptionStringValue[entries.length];
|
optValue = new OptionStringValue[entries.length];
|
||||||
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
|
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
|
||||||
|
|
||||||
|
@ -587,38 +579,37 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
ITool tool = fLangData.getTool();
|
ITool tool = fLangData.getTool();
|
||||||
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
||||||
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
||||||
options = fLangData.getOptionsForKind(kind);
|
for (IOption opt : fLangData.getOptionsForKind(kind)) {
|
||||||
for(int i = 0; i < options.length; i++){
|
if(opt != newOption)
|
||||||
if(options[i] != newOption)
|
ManagedBuildManager.setOption(rcInfo, tool, opt, new String[0]);
|
||||||
ManagedBuildManager.setOption(rcInfo, tool, options[i], new String[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List emptyEntryInfos){
|
private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List<EmptyEntryInfo> emptyEntryInfos){
|
||||||
if(emptyEntryInfos == null || emptyEntryInfos.size() == 0)
|
if(emptyEntryInfos == null || emptyEntryInfos.size() == 0)
|
||||||
return infos;
|
return infos;
|
||||||
|
|
||||||
LinkedList list = new LinkedList();
|
LinkedList<UserEntryInfo> list = new LinkedList<UserEntryInfo>();
|
||||||
list.addAll(Arrays.asList(infos));
|
list.addAll(Arrays.asList(infos));
|
||||||
for(int i = 0; i < emptyEntryInfos.size(); i++){
|
for(int i = 0; i < emptyEntryInfos.size(); i++){
|
||||||
EmptyEntryInfo ei = (EmptyEntryInfo)emptyEntryInfos.get(i);
|
EmptyEntryInfo ei = emptyEntryInfos.get(i);
|
||||||
int index = ei.fPosition;
|
int index = ei.fPosition;
|
||||||
if(index > list.size())
|
if(index > list.size())
|
||||||
index = list.size();
|
index = list.size();
|
||||||
|
|
||||||
list.add(index, new UserEntryInfo(null, ei.fOriginalValue, ei.fOriginalValue, null));
|
list.add(index, new UserEntryInfo(null, ei.fOriginalValue, ei.fOriginalValue, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UserEntryInfo[])list.toArray(new UserEntryInfo[list.size()]);
|
return list.toArray(new UserEntryInfo[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserEntryInfo[] combineSequenses(UserEntryInfo infos[]){
|
private UserEntryInfo[] combineSequenses(UserEntryInfo infos[]){
|
||||||
if(infos.length == 0)
|
if(infos.length == 0)
|
||||||
return infos;
|
return infos;
|
||||||
|
|
||||||
List list = new ArrayList(infos.length);
|
List<UserEntryInfo> list = new ArrayList<UserEntryInfo>(infos.length);
|
||||||
|
|
||||||
for(int i = 0; i < infos.length; i++){
|
for(int i = 0; i < infos.length; i++){
|
||||||
UserEntryInfo info = infos[i];
|
UserEntryInfo info = infos[i];
|
||||||
if(info.fSequense != null) {
|
if(info.fSequense != null) {
|
||||||
|
@ -634,9 +625,9 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(match){
|
if(match){
|
||||||
i = i + seqSize - 1;
|
i = i + seqSize - 1;
|
||||||
} else {
|
} else {
|
||||||
infos[i] = createDesecuencedEntry(info);
|
infos[i] = createDesecuencedEntry(info);
|
||||||
for(int k = i + 1; k < infos.length; k++){
|
for(int k = i + 1; k < infos.length; k++){
|
||||||
|
@ -648,42 +639,42 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
||||||
}
|
}
|
||||||
list.add(info);
|
list.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UserEntryInfo[])list.toArray(new UserEntryInfo[list.size()]);
|
return list.toArray(new UserEntryInfo[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UserEntryInfo createDesecuencedEntry(UserEntryInfo info){
|
private static UserEntryInfo createDesecuencedEntry(UserEntryInfo info){
|
||||||
OptionStringValue resolvedValue = info.fBsResolvedValue;
|
OptionStringValue resolvedValue = info.fBsResolvedValue;
|
||||||
if(resolvedValue != null){
|
if(resolvedValue != null){
|
||||||
String v = doubleQuotePath(resolvedValue.getValue(), true);
|
String v = doubleQuotePath(resolvedValue.getValue(), true);
|
||||||
if(v != null)
|
if(v != null)
|
||||||
resolvedValue = substituteValue(resolvedValue, v);
|
resolvedValue = substituteValue(resolvedValue, v);
|
||||||
}
|
}
|
||||||
return new UserEntryInfo(info.fEntry, resolvedValue, resolvedValue, null);
|
return new UserEntryInfo(info.fEntry, resolvedValue, resolvedValue, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUserUndefinedStringSet(Set set){
|
private void setUserUndefinedStringSet(Set<String> set){
|
||||||
int kind = getKind();
|
int kind = getKind();
|
||||||
IOption[] options = fLangData.getUndefOptionsForKind(kind);
|
IOption[] options = fLangData.getUndefOptionsForKind(kind);
|
||||||
if(options.length != 0){
|
if(options.length != 0){
|
||||||
if(set != null && set.size() == 0)
|
if(set != null && set.size() == 0)
|
||||||
set = null;
|
set = null;
|
||||||
|
|
||||||
String[] optValue = set != null ? (String[])set.toArray(new String[set.size()]) : new String[0];
|
String[] optValue = set != null ? (String[])set.toArray(new String[set.size()]) : new String[0];
|
||||||
IOption option = options[0];
|
IOption option = options[0];
|
||||||
ITool tool = fLangData.getTool();
|
ITool tool = fLangData.getTool();
|
||||||
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
IResourceInfo rcInfo = tool.getParentResourceInfo();
|
||||||
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
|
||||||
options = fLangData.getUndefOptionsForKind(kind);
|
options = fLangData.getUndefOptionsForKind(kind);
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
if(options[i] != newOption)
|
if(opt != newOption)
|
||||||
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void optionsChanged(){
|
void optionsChanged(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue