mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 11:15:38 +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 OptionStringValue fOriginalValue;
|
||||
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;
|
||||
fOriginalValue = originalValue;
|
||||
fBsResolvedValue = bsResolvedValue;
|
||||
|
@ -90,6 +90,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
fLangData = lData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SettingsSet createEmptySettings() {
|
||||
SettingsSet settings = new SettingsSet(3);
|
||||
SettingLevel levels[] = settings.getLevels();
|
||||
|
@ -125,6 +126,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
return fBuildDirName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
|
||||
switch(levelNum){
|
||||
case USER_ENTRIES_LEVEL:
|
||||
|
@ -139,7 +141,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
uei = new UserEntryInfo(infos[i].getEntry(), null, null, null);
|
||||
userInfos[i] = uei;
|
||||
}
|
||||
setUserEntries(userInfos, (List)level.getContext());
|
||||
setUserEntries(userInfos, (List<EmptyEntryInfo>)level.getContext());
|
||||
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
|
||||
}
|
||||
break;
|
||||
|
@ -147,31 +149,27 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
}
|
||||
|
||||
private void restoreDefaults(){
|
||||
IOption options[] = fLangData.getOptionsForKind(getKind());
|
||||
ITool tool = fLangData.getTool();
|
||||
for(int i = 0; i < options.length; i++){
|
||||
IOption option = options[i];
|
||||
for (IOption option : fLangData.getOptionsForKind(getKind())) {
|
||||
if(option.getParent() == tool){
|
||||
tool.removeOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
options = fLangData.getUndefOptionsForKind(getKind());
|
||||
for(int i = 0; i < options.length; i++){
|
||||
IOption option = options[i];
|
||||
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
|
||||
if(option.getParent() == tool){
|
||||
tool.removeOption(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putEntriesToLevel(int levelNum, SettingLevel level) {
|
||||
switch(levelNum){
|
||||
case USER_ENTRIES_LEVEL:
|
||||
List emptyEntryInfos = new ArrayList();
|
||||
UserEntryInfo[] userEntries = getUserEntries(level.getFlags(0), true, emptyEntryInfos);
|
||||
for(int i = 0; i < userEntries.length; i++){
|
||||
level.addEntry(userEntries[i].fEntry, userEntries[i]);
|
||||
List<EmptyEntryInfo> emptyEntryInfos = new ArrayList<EmptyEntryInfo>();
|
||||
for (UserEntryInfo userEntry : getUserEntries(level.getFlags(0), true, emptyEntryInfos)) {
|
||||
level.addEntry(userEntry.fEntry, userEntry);
|
||||
}
|
||||
level.addOverrideNameSet(getUserUndefinedStringSet());
|
||||
if(emptyEntryInfos.size() != 0)
|
||||
|
@ -211,19 +209,18 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
: 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());
|
||||
if(options.length > 0){
|
||||
List entryList = new ArrayList();
|
||||
for(int i = 0; i < options.length; i++){
|
||||
Option option = (Option)options[i];
|
||||
List list = usr ? (List)option.getExactValue() : option.getExactBuiltinsList();
|
||||
int size = list != null ? list.size() : 0;
|
||||
if(size > 0){
|
||||
List<UserEntryInfo> entryList = new ArrayList<UserEntryInfo>();
|
||||
for (IOption opt : options) {
|
||||
Option option = (Option)opt;
|
||||
List<OptionStringValue> list = usr ? (List<OptionStringValue>)option.getExactValue() : (List<OptionStringValue>)option.getExactBuiltinsList();
|
||||
if(list != null){
|
||||
SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
|
||||
SupplierBasedCdtVariableSubstitutor bSVarsSubst = createSubstitutor(option, true);
|
||||
for(int j = 0; j < size; j++){
|
||||
OptionStringValue ve = (OptionStringValue)list.get(j);
|
||||
for(int j = 0; j < list.size(); j++){
|
||||
OptionStringValue ve = list.get(j);
|
||||
OptionStringValue[] rVes = resolve(ve, option, bSVarsSubst);
|
||||
if(rVes.length == 0){
|
||||
if(emptyValuesInfos != null){
|
||||
|
@ -231,9 +228,8 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
}
|
||||
} else {
|
||||
boolean isMultiple = rVes.length > 1;
|
||||
List sequense = isMultiple ? new ArrayList(rVes.length) : null;
|
||||
for(int k = 0; k < rVes.length; k++){
|
||||
OptionStringValue rVe = rVes[k];
|
||||
List<UserEntryInfo> sequense = isMultiple ? new ArrayList<UserEntryInfo>(rVes.length) : null;
|
||||
for (OptionStringValue rVe : rVes) {
|
||||
ICLanguageSettingEntry entry = createUserEntry(option, rVe, flags, subst);
|
||||
entryList.add(new UserEntryInfo(entry, ve, rVe, sequense));
|
||||
}
|
||||
|
@ -242,7 +238,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
}
|
||||
}
|
||||
|
||||
return (UserEntryInfo[])entryList.toArray(new UserEntryInfo[entryList.size()]);
|
||||
return entryList.toArray(new UserEntryInfo[entryList.size()]);
|
||||
}
|
||||
return new UserEntryInfo[0];
|
||||
}
|
||||
|
@ -269,18 +265,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
return new OptionStringValue(value, ov.isBuiltIn(), ov.getSourceAttachmentPath(), ov.getSourceAttachmentRootPath(), ov.getSourceAttachmentPrefixMapping());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
private HashSet<String> getUserUndefinedStringSet(){
|
||||
HashSet<String> set = null;
|
||||
for (IOption option : fLangData.getUndefOptionsForKind(getKind())) {
|
||||
List<String> list = (List<String>)option.getValue();
|
||||
if(list.size() != 0){
|
||||
if(set == null)
|
||||
set = new HashSet<String>();
|
||||
set.addAll(list);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
|
@ -346,12 +338,12 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
String paths[] = null;
|
||||
int kind = getKind();
|
||||
switch(kind){
|
||||
case ICLanguageSettingEntry.INCLUDE_PATH:{
|
||||
case ICSettingEntry.INCLUDE_PATH:{
|
||||
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||
}
|
||||
break;
|
||||
case ICLanguageSettingEntry.LIBRARY_PATH:{
|
||||
case ICSettingEntry.LIBRARY_PATH:{
|
||||
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||
paths = provider.getBuildPaths(fLangData.getConfiguration(), IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||
}
|
||||
|
@ -369,7 +361,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
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){
|
||||
int kind = getKind();
|
||||
|
||||
|
@ -378,18 +370,17 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;
|
||||
|
||||
switch (kind){
|
||||
case ICLanguageSettingEntry.MACRO:
|
||||
case ICSettingEntry.MACRO:
|
||||
String nv[] = macroNameValueFromValue(optionValue.getValue());
|
||||
// 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:
|
||||
case ICLanguageSettingEntry.LIBRARY_FILE:
|
||||
// case ICSettingEntry.INCLUDE_PATH:
|
||||
// case ICSettingEntry.INCLUDE_FILE:
|
||||
// case ICSettingEntry.MACRO_FILE:
|
||||
// case ICSettingEntry.LIBRARY_PATH:
|
||||
case ICSettingEntry.LIBRARY_FILE:
|
||||
String tmp = optionValue.getSourceAttachmentPath();
|
||||
if(tmp != null)
|
||||
srcPath = new Path(tmp);
|
||||
|
@ -400,6 +391,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
if(tmp != null)
|
||||
srcPrefixMapping = new Path(tmp);
|
||||
//do not break
|
||||
//$FALL-THROUGH$
|
||||
default:
|
||||
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
|
||||
PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst);
|
||||
|
@ -407,7 +399,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
// Object[] v = optionPathValueToEntry(optionValue);
|
||||
|
||||
if(pInfo.isWorkspacePath()){
|
||||
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
} else if (optionPathConverter != null){
|
||||
IPath path = optionPathConverter.convertToPlatformLocation(pInfo.getUnresolvedPath(), option, fLangData.getTool());
|
||||
if(path != null){
|
||||
|
@ -450,7 +442,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){
|
||||
String result;
|
||||
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();
|
||||
} else if(entry instanceof ICLanguageSettingPathEntry){
|
||||
IOptionPathConverter converter = fLangData.getTool().getOptionPathConverter();
|
||||
|
@ -511,7 +503,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
boolean quoted = false;
|
||||
|
||||
/* 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$
|
||||
|
||||
/* If indexof didn't fail all three times, double-quote path */
|
||||
|
@ -563,7 +555,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
return new PathInfo(unresolvedStr, isWorkspacePath, subst);
|
||||
}
|
||||
|
||||
private void setUserEntries(UserEntryInfo[] entries, List emptyEntryInfos){
|
||||
private void setUserEntries(UserEntryInfo[] entries, List<EmptyEntryInfo> emptyEntryInfos){
|
||||
int kind = getKind();
|
||||
IOption options[] = fLangData.getOptionsForKind(kind);
|
||||
if(options.length != 0){
|
||||
|
@ -587,22 +579,21 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
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, options[i], new String[0]);
|
||||
for (IOption opt : fLangData.getOptionsForKind(kind)) {
|
||||
if(opt != newOption)
|
||||
ManagedBuildManager.setOption(rcInfo, tool, opt, new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List emptyEntryInfos){
|
||||
private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List<EmptyEntryInfo> emptyEntryInfos){
|
||||
if(emptyEntryInfos == null || emptyEntryInfos.size() == 0)
|
||||
return infos;
|
||||
|
||||
LinkedList list = new LinkedList();
|
||||
LinkedList<UserEntryInfo> list = new LinkedList<UserEntryInfo>();
|
||||
list.addAll(Arrays.asList(infos));
|
||||
for(int i = 0; i < emptyEntryInfos.size(); i++){
|
||||
EmptyEntryInfo ei = (EmptyEntryInfo)emptyEntryInfos.get(i);
|
||||
EmptyEntryInfo ei = emptyEntryInfos.get(i);
|
||||
int index = ei.fPosition;
|
||||
if(index > list.size())
|
||||
index = list.size();
|
||||
|
@ -610,14 +601,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
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[]){
|
||||
if(infos.length == 0)
|
||||
return infos;
|
||||
|
||||
List list = new ArrayList(infos.length);
|
||||
List<UserEntryInfo> list = new ArrayList<UserEntryInfo>(infos.length);
|
||||
|
||||
for(int i = 0; i < infos.length; i++){
|
||||
UserEntryInfo info = infos[i];
|
||||
|
@ -649,7 +640,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
list.add(info);
|
||||
}
|
||||
|
||||
return (UserEntryInfo[])list.toArray(new UserEntryInfo[list.size()]);
|
||||
return list.toArray(new UserEntryInfo[list.size()]);
|
||||
}
|
||||
|
||||
private static UserEntryInfo createDesecuencedEntry(UserEntryInfo info){
|
||||
|
@ -662,7 +653,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
return new UserEntryInfo(info.fEntry, resolvedValue, resolvedValue, null);
|
||||
}
|
||||
|
||||
private void setUserUndefinedStringSet(Set set){
|
||||
private void setUserUndefinedStringSet(Set<String> set){
|
||||
int kind = getKind();
|
||||
IOption[] options = fLangData.getUndefOptionsForKind(kind);
|
||||
if(options.length != 0){
|
||||
|
@ -675,8 +666,8 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
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)
|
||||
for (IOption opt : options) {
|
||||
if(opt != newOption)
|
||||
ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue