1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-05-25 03:03:13 +00:00
parent b8e33bce4f
commit df89f7be87

View file

@ -70,12 +70,12 @@ public class BuildEntryStorage extends AbstractEntryStorage {
private OptionStringValue fBsResolvedValue; private OptionStringValue fBsResolvedValue;
private List<UserEntryInfo> fSequense; private List<UserEntryInfo> fSequense;
UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue originalValue, OptionStringValue bsResolvedValue, List<UserEntryInfo> sequense){ UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue originalValue, OptionStringValue bsResolvedValue, List<UserEntryInfo> sequense) {
fEntry = entry; fEntry = entry;
fOriginalValue = originalValue; fOriginalValue = originalValue;
fBsResolvedValue = bsResolvedValue; fBsResolvedValue = bsResolvedValue;
fSequense = sequense; fSequense = sequense;
if(sequense != null) if (sequense != null)
sequense.add(this); sequense.add(this);
} }
} }
@ -84,7 +84,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
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;
} }
@ -121,12 +121,12 @@ 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;
} }
private String getBuildDitName(){ private String getBuildDitName() {
if(fBuildDirName == null){ if (fBuildDirName == null) {
fBuildDirName = fLangData.getConfiguration().getName(); fBuildDirName = fLangData.getConfiguration().getName();
} }
return fBuildDirName; return fBuildDirName;
@ -134,16 +134,16 @@ public class BuildEntryStorage extends AbstractEntryStorage {
@Override @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:
if(level == null) if (level == null) {
restoreDefaults(); restoreDefaults();
else { } else {
EntryInfo infos[] = level.getInfos(); EntryInfo infos[] = level.getInfos();
UserEntryInfo[] userInfos = new UserEntryInfo[infos.length]; UserEntryInfo[] userInfos = new UserEntryInfo[infos.length];
for(int i = 0; i < infos.length; i++){ for (int i = 0; i < infos.length; i++) {
UserEntryInfo uei = (UserEntryInfo)infos[i].getCustomInfo(); UserEntryInfo uei = (UserEntryInfo)infos[i].getCustomInfo();
if(uei == null) if (uei == null)
uei = new UserEntryInfo(infos[i].getEntry(), null, null, null); uei = new UserEntryInfo(infos[i].getEntry(), null, null, null);
userInfos[i] = uei; userInfos[i] = uei;
} }
@ -156,16 +156,16 @@ public class BuildEntryStorage extends AbstractEntryStorage {
} }
} }
private void restoreDefaults(){ private void restoreDefaults() {
ITool tool = fLangData.getTool(); ITool tool = fLangData.getTool();
for (IOption option : fLangData.getOptionsForKind(getKind())) { for (IOption option : fLangData.getOptionsForKind(getKind())) {
if(option.getParent() == tool){ if (option.getParent() == tool) {
tool.removeOption(option); tool.removeOption(option);
} }
} }
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) { for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
if(option.getParent() == tool){ if (option.getParent() == tool) {
tool.removeOption(option); tool.removeOption(option);
} }
} }
@ -173,14 +173,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
@Override @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<EmptyEntryInfo> emptyEntryInfos = new ArrayList<EmptyEntryInfo>(); List<EmptyEntryInfo> emptyEntryInfos = new ArrayList<EmptyEntryInfo>();
for (UserEntryInfo userEntry : getUserEntries(level.getFlags(0), true, emptyEntryInfos)) { for (UserEntryInfo userEntry : getUserEntries(level.getFlags(0), true, emptyEntryInfos)) {
level.addEntry(userEntry.fEntry, userEntry); level.addEntry(userEntry.fEntry, userEntry);
} }
level.addOverrideNameSet(getUserUndefinedStringSet()); level.addOverrideNameSet(getUserUndefinedStringSet());
if(emptyEntryInfos.size() != 0) if (emptyEntryInfos.size() != 0)
level.setContext(emptyEntryInfos); level.setContext(emptyEntryInfos);
break; break;
case ENV_ENTRIES_LEVEL: case ENV_ENTRIES_LEVEL:
@ -197,13 +197,13 @@ public class BuildEntryStorage extends AbstractEntryStorage {
/** /**
* @return scanner discovered entries (level 2) * @return scanner discovered entries (level 2)
*/ */
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) {
UserEntryInfo[] infos = getUserEntries(flags, false, null); UserEntryInfo[] infos = getUserEntries(flags, false, null);
if(infos.length != 0){ if (infos.length != 0) {
entries = new ICLanguageSettingEntry[infos.length]; entries = new ICLanguageSettingEntry[infos.length];
for(int i = 0; i < entries.length; i++){ for (int i = 0; i < entries.length; i++) {
entries[i] = infos[i].fEntry; entries[i] = infos[i].fEntry;
} }
} }
@ -211,13 +211,13 @@ 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$
} }
/** /**
@ -228,23 +228,23 @@ public class BuildEntryStorage extends AbstractEntryStorage {
* @param emptyValuesInfos list to which unresolved entries are added * @param emptyValuesInfos list to which unresolved entries are added
* @return UserEntryInfo[] (never null) * @return UserEntryInfo[] (never null)
*/ */
private UserEntryInfo[] getUserEntries(int flags, boolean usr, List<EmptyEntryInfo> 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<UserEntryInfo> entryList = new ArrayList<UserEntryInfo>(); List<UserEntryInfo> entryList = new ArrayList<UserEntryInfo>();
for (IOption opt : options) { for (IOption opt : options) {
Option option = (Option)opt; Option option = (Option)opt;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<OptionStringValue> list = usr ? (List<OptionStringValue>)option.getExactValue() : (List<OptionStringValue>)option.getExactBuiltinsList(); List<OptionStringValue> list = usr ? (List<OptionStringValue>)option.getExactValue() : (List<OptionStringValue>)option.getExactBuiltinsList();
if(list != null){ if (list != null) {
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 < list.size(); j++){ for (int j = 0; j < list.size(); j++) {
OptionStringValue ve = 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 not resolved, add EmptyEntryInfo based off the value entry // If not resolved, add EmptyEntryInfo based off the value entry
if(emptyValuesInfos != null){ if (emptyValuesInfos != null) {
emptyValuesInfos.add(new EmptyEntryInfo(ve, j)); emptyValuesInfos.add(new EmptyEntryInfo(ve, j));
} }
} else { } else {
@ -265,35 +265,35 @@ public class BuildEntryStorage extends AbstractEntryStorage {
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);
// if(value != null){ // if (value != null) {
// value = value.substring(1, value.length() - 1); // value = value.substring(1, value.length() - 1);
// ov = substituteValue(ov, value); // ov = substituteValue(ov, value);
// } // }
// 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<String> getUserUndefinedStringSet(){ private HashSet<String> getUserUndefinedStringSet() {
HashSet<String> set = null; HashSet<String> set = null;
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) { for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<String> list = (List<String>)option.getValue(); List<String> list = (List<String>)option.getValue();
if(list.size() != 0){ if (list.size() != 0) {
if(set == null) if (set == null)
set = new HashSet<String>(); set = new HashSet<String>();
set.addAll(list); set.addAll(list);
} }
@ -304,13 +304,13 @@ public class BuildEntryStorage extends AbstractEntryStorage {
/** /**
* Makes non-absolute paths relative to the build directory * Makes non-absolute paths relative to the build directory
*/ */
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$
projPath = path.removeFirstSegments(1).toString(); projPath = path.removeFirstSegments(1).toString();
} else { } else {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
@ -320,13 +320,13 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor()); return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor());
} }
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))) {
projPath = path.removeFirstSegments(1).toString(); projPath = path.removeFirstSegments(1).toString();
} else { } else {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
@ -336,11 +336,11 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor()); return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor());
} }
// 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) {
try { try {
return CdtVariableResolver.resolveToStringList(v, sub); return CdtVariableResolver.resolveToStringList(v, sub);
} catch (CdtVariableException e) { } catch (CdtVariableException e) {
@ -349,12 +349,12 @@ 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);
String[] rValues = resolve(value, option, sub); String[] rValues = resolve(value, option, sub);
OptionStringValue[] result = new OptionStringValue[rValues.length]; OptionStringValue[] result = new OptionStringValue[rValues.length];
for(int i = 0; i < result.length; i++){ for (int i = 0; i < result.length; i++) {
result[i] = substituteValue(ov, stripQuotes(rValues[i], false)); result[i] = substituteValue(ov, stripQuotes(rValues[i], false));
} }
return result; return result;
@ -363,10 +363,10 @@ public class BuildEntryStorage extends AbstractEntryStorage {
/** /**
* @return env entries (level 1) * @return env entries (level 1)
*/ */
private ICLanguageSettingEntry[] getEnvEntries(int flags){ private ICLanguageSettingEntry[] getEnvEntries(int flags) {
String paths[] = null; String paths[] = null;
int kind = getKind(); int kind = getKind();
switch(kind){ switch(kind) {
case ICSettingEntry.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);
@ -379,9 +379,9 @@ public class BuildEntryStorage extends AbstractEntryStorage {
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);
} }
@ -393,7 +393,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
/** /**
* Create an ICLanguageSettingEntry based on the passed in Option * Create an ICLanguageSettingEntry based on the passed in Option
*/ */
private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags, SupplierBasedCdtVariableSubstitutor subst){ private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags, SupplierBasedCdtVariableSubstitutor subst) {
final int kind = getKind(); final int kind = getKind();
if (kind == ICSettingEntry.MACRO) { if (kind == ICSettingEntry.MACRO) {
@ -407,19 +407,19 @@ public class BuildEntryStorage extends AbstractEntryStorage {
// Create a PathInfo entry representing the optionValue // Create a PathInfo entry representing the optionValue
PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst); PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst);
if(pInfo.isWorkspacePath()){ if (pInfo.isWorkspacePath()) {
flags |= ICSettingEntry.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);
} }
} }
// make non absolute paths relative to the build directory // make non absolute paths relative to the build directory
if (getOptionType(option) != IOption.LIBRARIES) if (getOptionType(option) != IOption.LIBRARIES) {
pInfo = fromBuildToProj(pInfo); pInfo = fromBuildToProj(pInfo);
else { } else {
// The IOption.LIBRARIES type is morphed to => ICSettingEntyr#LIBRARY_FILE // The IOption.LIBRARIES type is morphed to => ICSettingEntyr#LIBRARY_FILE
// It *isn't* a workspace path! // It *isn't* a workspace path!
flags &= ~ICSettingEntry.VALUE_WORKSPACE_PATH; flags &= ~ICSettingEntry.VALUE_WORKSPACE_PATH;
@ -433,29 +433,29 @@ public class BuildEntryStorage extends AbstractEntryStorage {
if (kind == ICSettingEntry.LIBRARY_FILE) { if (kind == ICSettingEntry.LIBRARY_FILE) {
// Handle source types // Handle source types
String tmp = optionValue.getSourceAttachmentPath(); String tmp = optionValue.getSourceAttachmentPath();
if(tmp != null) if (tmp != null)
srcPath = new Path(tmp); srcPath = new Path(tmp);
tmp = optionValue.getSourceAttachmentRootPath(); tmp = optionValue.getSourceAttachmentRootPath();
if(tmp != null) if (tmp != null)
srcRootPath = new Path(tmp); srcRootPath = new Path(tmp);
tmp = optionValue.getSourceAttachmentPrefixMapping(); tmp = optionValue.getSourceAttachmentPrefixMapping();
if(tmp != null) if (tmp != null)
srcPrefixMapping = new Path(tmp); srcPrefixMapping = new Path(tmp);
} }
return (ICLanguageSettingEntry)CDataUtil.createEntry(kind, pInfo.getUnresolvedPath(), null, null, flags, srcPath, srcRootPath, srcPrefixMapping); return (ICLanguageSettingEntry)CDataUtil.createEntry(kind, pInfo.getUnresolvedPath(), null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
} }
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);
} }
private OptionStringValue entryValueToOption(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){ private OptionStringValue entryValueToOption(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst) {
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,
@ -466,18 +466,18 @@ 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;
} }
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() == ICSettingEntry.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();
if(converter instanceof IReverseOptionPathConverter){ if (converter instanceof IReverseOptionPathConverter) {
result = ((IReverseOptionPathConverter)converter).convertToOptionValue(entry, option, fLangData.getTool()); result = ((IReverseOptionPathConverter)converter).convertToOptionValue(entry, option, fLangData.getTool());
checkQuote = false; checkQuote = false;
} else { } else {
@ -488,21 +488,21 @@ public class BuildEntryStorage extends AbstractEntryStorage {
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);
String result; String result;
if(isWsp){ if (isWsp) {
if(!pInfo.isAbsolute()){ if (!pInfo.isAbsolute()) {
IConfiguration cfg = fLangData.getConfiguration(); IConfiguration cfg = fLangData.getConfiguration();
IResource rc = cfg.getOwner(); IResource rc = cfg.getOwner();
if(rc != null){ if (rc != null) {
IProject proj = rc.getProject(); IProject proj = rc.getProject();
String path = pInfo.getUnresolvedPath(); String path = pInfo.getUnresolvedPath();
IPath p = proj.getFullPath().append(path); IPath p = proj.getFullPath().append(path);
@ -554,25 +554,25 @@ public class BuildEntryStorage extends AbstractEntryStorage {
/* 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) {
pathName = "\"" + pathName; //$NON-NLS-1$ pathName = "\"" + pathName; //$NON-NLS-1$
quoted = true; quoted = true;
} }
if (!bEndsWithQuote){ if (!bEndsWithQuote) {
pathName = pathName + "\""; //$NON-NLS-1$ pathName = pathName + "\""; //$NON-NLS-1$
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('=');
if(index > 0){ if (index > 0) {
nv[0] = value.substring(0, index); nv[0] = value.substring(0, index);
nv[1] = value.substring(index + 1); nv[1] = value.substring(index + 1);
} else { } else {
@ -582,17 +582,17 @@ 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;
if(unresolvedStr != null){ if (unresolvedStr != null) {
isWorkspacePath = true; isWorkspacePath = true;
} else { } else {
unresolvedStr = str; unresolvedStr = str;
@ -601,17 +601,17 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new PathInfo(unresolvedStr, isWorkspacePath, subst); return new PathInfo(unresolvedStr, isWorkspacePath, subst);
} }
private void setUserEntries(UserEntryInfo[] entries, List<EmptyEntryInfo> 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);
// We don't expect more than one option to manage a particular entry kind, though it // We don't expect more than one option to manage a particular entry kind, though it
// is theoretically possible... Add a trace for Toolchain developers // is theoretically possible... Add a trace for Toolchain developers
if (options.length > 1) if (options.length > 1)
ManagedBuilderCorePlugin.error("Unexpected error: Warning more than one options found for kind " + getKind()); //$NON-NLS-1$ ManagedBuilderCorePlugin.error("Unexpected error: Warning more than one options found for kind " + getKind()); //$NON-NLS-1$
if(options.length != 0) { if (options.length != 0) {
IOption option = options[0]; IOption option = options[0];
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);
@ -619,7 +619,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
optValue = new OptionStringValue[entries.length]; optValue = new OptionStringValue[entries.length];
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false); SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
for(int i = 0; i < entries.length; i++){ for (int i = 0; i < entries.length; i++) {
optValue[i] = createOptionValue(option, entries[i], subst); optValue[i] = createOptionValue(option, entries[i], subst);
} }
} else { } else {
@ -630,22 +630,22 @@ public class BuildEntryStorage extends AbstractEntryStorage {
IResourceInfo rcInfo = tool.getParentResourceInfo(); IResourceInfo rcInfo = tool.getParentResourceInfo();
IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue); IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
for (IOption opt : fLangData.getOptionsForKind(kind)) { for (IOption opt : fLangData.getOptionsForKind(kind)) {
if(opt != newOption) if (opt != newOption)
ManagedBuildManager.setOption(rcInfo, tool, opt, new String[0]); ManagedBuildManager.setOption(rcInfo, tool, opt, new String[0]);
} }
} }
} }
private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List<EmptyEntryInfo> 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<UserEntryInfo> list = new LinkedList<UserEntryInfo>(); 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 = 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));
@ -662,34 +662,34 @@ public class BuildEntryStorage extends AbstractEntryStorage {
* FIXME: As far as I can see info.fSequense only ever has a single entry in it... * FIXME: As far as I can see info.fSequense only ever has a single entry in it...
* see UserEntryInfo constructor => this method doesn't accomplish anything useful * see UserEntryInfo constructor => this method doesn't accomplish anything useful
*/ */
private UserEntryInfo[] combineSequenses(UserEntryInfo infos[]){ private UserEntryInfo[] combineSequenses(UserEntryInfo infos[]) {
if(infos.length == 0) if (infos.length == 0)
return infos; return infos;
List<UserEntryInfo> list = new ArrayList<UserEntryInfo>(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) {
boolean match = true; boolean match = true;
int seqSize = info.fSequense.size(); int seqSize = info.fSequense.size();
if(seqSize > infos.length - i) if (seqSize > infos.length - i) {
match = false; match = false;
else { } else {
for(int k = 0; k < seqSize; k++){ for (int k = 0; k < seqSize; k++) {
if(info.fSequense.get(k) != infos[i + k]){ if (info.fSequense.get(k) != infos[i + k]) {
match = false; match = false;
break; break;
} }
} }
} }
if(match){ if (match) {
i = i + seqSize - 1; i = i + seqSize - 1;
} else { } else {
infos[i] = createDesequencedEntry(info); infos[i] = createDesequencedEntry(info);
for(int k = i + 1; k < infos.length; k++){ for (int k = i + 1; k < infos.length; k++) {
if(infos[k].fSequense == info.fSequense) if (infos[k].fSequense == info.fSequense)
infos[k] = createDesequencedEntry(infos[k]); infos[k] = createDesequencedEntry(infos[k]);
} }
info = infos[i]; info = infos[i];
@ -701,21 +701,21 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return list.toArray(new UserEntryInfo[list.size()]); return list.toArray(new UserEntryInfo[list.size()]);
} }
private static UserEntryInfo createDesequencedEntry(UserEntryInfo info){ private static UserEntryInfo createDesequencedEntry(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<String> 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];
@ -725,14 +725,12 @@ public class BuildEntryStorage extends AbstractEntryStorage {
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 (IOption opt : options) { for (IOption opt : options) {
if(opt != newOption) if (opt != newOption)
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]); ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
} }
}
} }
} void optionsChanged() {
void optionsChanged(){
} }
} }