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

cosmetics: enhanced loops etc

This commit is contained in:
Andrew Gvozdev 2010-01-19 22:30:10 +00:00
parent 4e5503ab5c
commit 63a3c860fe

View file

@ -192,8 +192,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
try { try {
monitor.beginTask(fName, fRunnables.size()); monitor.beginTask(fName, fRunnables.size());
for(Iterator<IWorkspaceRunnable> iter = fRunnables.iterator(); iter.hasNext();){ for (IWorkspaceRunnable r : fRunnables) {
IWorkspaceRunnable r = iter.next();
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
try { try {
r.run(subMonitor); r.run(subMonitor);
@ -288,18 +287,18 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
/** /**
* *
* @param from Project to move the description from * @param from Project to move the description from
* @param to Project where the description is moved to * @param to Project where the description is moved to
* @return <b>ICProjectDescription</b> - non serialized, modified, writable * @return <b>ICProjectDescription</b> - non serialized, modified, writable
* project description. To serialize, call <code>setProjectDescription()</code> * project description. To serialize, call <code>setProjectDescription()</code>
* *
*/ */
public ICProjectDescription projectMove(IProject from, IProject to) { public ICProjectDescription projectMove(IProject from, IProject to) {
CProjectDescriptionStorageManager.getInstance().projectMove(from, to); CProjectDescriptionStorageManager.getInstance().projectMove(from, to);
int flags = CProjectDescriptionManager.INTERNAL_GET_IGNORE_CLOSE | int flags = CProjectDescriptionManager.INTERNAL_GET_IGNORE_CLOSE |
CProjectDescriptionManager.GET_WRITABLE; ICProjectDescriptionManager.GET_WRITABLE;
CProjectDescription des = (CProjectDescription)getProjectDescription(to, flags); CProjectDescription des = (CProjectDescription)getProjectDescription(to, flags);
// set configuration descriptions to "writable" state // set configuration descriptions to "writable" state
for (ICConfigurationDescription cfgDes : des.getConfigurations()) { for (ICConfigurationDescription cfgDes : des.getConfigurations()) {
@ -513,8 +512,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
projects = wsp.getRoot().getProjects(); projects = wsp.getRoot().getProjects();
final ICProjectDescription dess[] = new ICProjectDescription[projects.length]; final ICProjectDescription dess[] = new ICProjectDescription[projects.length];
int num = 0; int num = 0;
for(int i = 0; i < projects.length; i++){ for (IProject project : projects) {
ICProjectDescription des = getProjectDescription(projects[i], false, true); ICProjectDescription des = getProjectDescription(project, false, true);
if(des != null) if(des != null)
dess[num++] = des; dess[num++] = des;
} }
@ -527,8 +526,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
public void run(IProgressMonitor monitor) throws CoreException { public void run(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(SettingsModelMessages.getString("CProjectDescriptionManager.13"), fi[0]); //$NON-NLS-1$ monitor.beginTask(SettingsModelMessages.getString("CProjectDescriptionManager.13"), fi[0]); //$NON-NLS-1$
for(int i = 0; i < dess.length; i++){ for (ICProjectDescription des : dess) {
ICProjectDescription des = dess[i];
if(des == null) if(des == null)
break; break;
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
@ -553,10 +551,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
public ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des){ public ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des){
CProjectConverterDesciptor[] converterDess = getConverterDescriptors(); CProjectConverterDesciptor[] converterDess = getConverterDescriptors();
ICProjectConverter converter = null; ICProjectConverter converter = null;
for(int i = 0; i < converterDess.length; i++){ for (CProjectConverterDesciptor converterDes : converterDess) {
if(converterDess[i].canConvertProject(project, oldOwnerId, des)){ if(converterDes.canConvertProject(project, oldOwnerId, des)){
try { try {
converter = converterDess[i].getConverter(); converter = converterDes.getConverter();
} catch (CoreException e) { } catch (CoreException e) {
} }
if(converter != null) if(converter != null)
@ -927,10 +925,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){ public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){
for(int i = 0; i < settings.length; i++){ for (ICLanguageSetting setting : settings) {
String ids[] = settings[i].getSourceContentTypeIds(); String ids[] = setting.getSourceContentTypeIds();
if(ListComparator.indexOf(id, ids) != -1) if(ListComparator.indexOf(id, ids) != -1)
return settings[i]; return setting;
} }
return null; return null;
} }
@ -943,8 +941,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(exts != null && exts.length != 0){ if(exts != null && exts.length != 0){
List<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>(); List<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>();
ICLanguageSetting setting; ICLanguageSetting setting;
for(int i = 0; i < exts.length; i++){ for (String ext : exts) {
setting = findLanguageSettingForExtension(exts[i], settings/*, src*/); setting = findLanguageSettingForExtension(ext, settings/*, src*/);
if(setting != null) if(setting != null)
list.add(setting); list.add(setting);
} }
@ -955,9 +953,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
public ICLanguageSetting findLanguageSettingForExtension(String ext, ICLanguageSetting settings[]/*, boolean src*/){ public ICLanguageSetting findLanguageSettingForExtension(String ext, ICLanguageSetting settings[]/*, boolean src*/){
ICLanguageSetting setting; for (ICLanguageSetting setting : settings) {
for(int i = 0; i < settings.length; i++){
setting = settings[i];
String exts[] = setting.getSourceExtensions(); String exts[] = setting.getSourceExtensions();
/* if(src){ /* if(src){
if(setting.getSourceContentType() == null){ if(setting.getSourceContentType() == null){
@ -970,8 +966,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
*/ */
if(exts != null && exts.length != 0){ if(exts != null && exts.length != 0){
for(int j = 0; j < exts.length; j++){ for (String ex: exts) {
if(ext.equals(exts[j])) if(ext.equals(ex))
return setting; return setting;
} }
} }
@ -992,8 +988,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(rootElement != null){ if(rootElement != null){
ICStorageElement children[] = rootElement.getChildren(); ICStorageElement children[] = rootElement.getChildren();
for(int i = 0; i < children.length; i++){ for (ICStorageElement el : children) {
ICStorageElement el = children[i];
if(CONFIGURATION.equals(el.getName())){ if(CONFIGURATION.equals(el.getName())){
String id = el.getAttribute(CConfigurationSpecSettings.ID); String id = el.getAttribute(CConfigurationSpecSettings.ID);
if(id != null) if(id != null)
@ -1016,10 +1011,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
ICStorageElement children[] = rootElement.getChildren(); ICStorageElement children[] = rootElement.getChildren();
ICStorageElement element = null; ICStorageElement element = null;
for(int i = 0; i < children.length; i++){ for (ICStorageElement el : children) {
if(CONFIGURATION.equals(children[i].getName()) if(CONFIGURATION.equals(el.getName())
&& cfgId.equals(children[i].getAttribute(CConfigurationSpecSettings.ID))){ && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))){
element = children[i]; element = el;
break; break;
} }
} }
@ -1068,10 +1063,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(rootElement != null){ if(rootElement != null){
ICStorageElement children[] = rootElement.getChildren(); ICStorageElement children[] = rootElement.getChildren();
for(int i = 0; i < children.length; i++){ for (ICStorageElement el: children) {
if(CONFIGURATION.equals(children[i].getName()) if(CONFIGURATION.equals(el.getName())
&& cfgId.equals(children[i].getAttribute(CConfigurationSpecSettings.ID))){ && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))){
rootElement.removeChild(children[i]); rootElement.removeChild(el);
break; break;
} }
} }
@ -1152,8 +1147,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
IExtension exts[] = extensionPoint.getExtensions(); IExtension exts[] = extensionPoint.getExtensions();
fProviderMap = new HashMap<String, CConfigurationDataProviderDescriptor>(exts.length); fProviderMap = new HashMap<String, CConfigurationDataProviderDescriptor>(exts.length);
for(int i = 0; i < exts.length; i++){ for (IExtension ext : exts) {
CConfigurationDataProviderDescriptor des = new CConfigurationDataProviderDescriptor(exts[i]); CConfigurationDataProviderDescriptor des = new CConfigurationDataProviderDescriptor(ext);
fProviderMap.put(des.getId(), des); fProviderMap.put(des.getId(), des);
} }
} }
@ -1278,19 +1273,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
ICConfigurationDescription[] cfgs = newDescription.getConfigurations(); ICConfigurationDescription[] cfgs = newDescription.getConfigurations();
for(int i = 0; i < cfgs.length; i++){ for (ICConfigurationDescription cfg : cfgs) {
ICConfigurationDescription oldCfg = oldDescription.getConfigurationById(cfgs[i].getId()); ICConfigurationDescription oldCfg = oldDescription.getConfigurationById(cfg.getId());
CProjectDescriptionDelta cfgDelta = createDelta(cfgs[i], oldCfg); CProjectDescriptionDelta cfgDelta = createDelta(cfg, oldCfg);
if(cfgDelta != null){ if(cfgDelta != null){
delta.addChild(cfgDelta); delta.addChild(cfgDelta);
} }
} }
cfgs = oldDescription.getConfigurations(); cfgs = oldDescription.getConfigurations();
for(int i = 0; i < cfgs.length; i++){ for (ICConfigurationDescription cfg : cfgs) {
ICConfigurationDescription newCfg = newDescription.getConfigurationById(cfgs[i].getId()); ICConfigurationDescription newCfg = newDescription.getConfigurationById(cfg.getId());
if(newCfg == null) if(newCfg == null)
delta.addChild(createDelta(null, cfgs[i])); delta.addChild(createDelta(null, cfg));
} }
if(checkCfgChange(newDescription, oldDescription, true)) if(checkCfgChange(newDescription, oldDescription, true))
@ -1344,10 +1339,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
private ICDescriptionDelta findDelta(String id, ICDescriptionDelta delta){ private ICDescriptionDelta findDelta(String id, ICDescriptionDelta delta){
ICDescriptionDelta children[] = delta.getChildren(); ICDescriptionDelta children[] = delta.getChildren();
ICSettingObject obj; ICSettingObject obj;
for(int i = 0; i < children.length; i++){ for (ICDescriptionDelta child : children) {
obj = children[i].getSetting(); obj = child.getSetting();
if(obj.getId().equals(id)) if(obj.getId().equals(id))
return children[i]; return child;
} }
return null; return null;
} }
@ -1408,42 +1403,42 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
IInternalCCfgInfo oldInfo = (IInternalCCfgInfo)oldCfg; IInternalCCfgInfo oldInfo = (IInternalCCfgInfo)oldCfg;
if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
ICFolderDescription[] foDess = newCfg.getFolderDescriptions(); ICFolderDescription[] foDess = newCfg.getFolderDescriptions();
for(int i = 0; i < foDess.length; i++){ for (ICFolderDescription foDes : foDess) {
ICResourceDescription oldDes = oldCfg.getResourceDescription(foDess[i].getPath(), true); ICResourceDescription oldDes = oldCfg.getResourceDescription(foDes.getPath(), true);
if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FOLDER){ if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FOLDER){
CProjectDescriptionDelta foDelta = createDelta(foDess[i], (ICFolderDescription)oldDes); CProjectDescriptionDelta foDelta = createDelta(foDes, (ICFolderDescription)oldDes);
if(foDelta != null) if(foDelta != null)
delta.addChild(foDelta); delta.addChild(foDelta);
} else { } else {
delta.addChild(createDelta(foDess[i], null)); delta.addChild(createDelta(foDes, null));
} }
} }
foDess = oldCfg.getFolderDescriptions(); foDess = oldCfg.getFolderDescriptions();
for(int i = 0; i < foDess.length; i++){ for (ICFolderDescription foDes : foDess) {
ICResourceDescription newDes = newCfg.getResourceDescription(foDess[i].getPath(), true); ICResourceDescription newDes = newCfg.getResourceDescription(foDes.getPath(), true);
if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FOLDER){ if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FOLDER){
delta.addChild(createDelta(null, foDess[i])); delta.addChild(createDelta(null, foDes));
} }
} }
ICFileDescription[] fiDess = newCfg.getFileDescriptions(); ICFileDescription[] fiDess = newCfg.getFileDescriptions();
for(int i = 0; i < fiDess.length; i++){ for (ICFileDescription fiDes : fiDess) {
ICResourceDescription oldDes = oldCfg.getResourceDescription(fiDess[i].getPath(), true); ICResourceDescription oldDes = oldCfg.getResourceDescription(fiDes.getPath(), true);
if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FILE){ if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FILE){
CProjectDescriptionDelta fiDelta = createDelta(fiDess[i], (ICFileDescription)oldDes); CProjectDescriptionDelta fiDelta = createDelta(fiDes, (ICFileDescription)oldDes);
if(fiDelta != null) if(fiDelta != null)
delta.addChild(fiDelta); delta.addChild(fiDelta);
} else { } else {
delta.addChild(createDelta(fiDess[i], null)); delta.addChild(createDelta(fiDes, null));
} }
} }
fiDess = oldCfg.getFileDescriptions(); fiDess = oldCfg.getFileDescriptions();
for(int i = 0; i < fiDess.length; i++){ for (ICFileDescription fiDes : fiDess) {
ICResourceDescription newDes = newCfg.getResourceDescription(fiDess[i].getPath(), true); ICResourceDescription newDes = newCfg.getResourceDescription(fiDes.getPath(), true);
if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FILE){ if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FILE){
delta.addChild(createDelta(null, fiDess[i])); delta.addChild(createDelta(null, fiDes));
} }
} }
@ -1469,12 +1464,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(newEntries.length > oldEntries.length){ if(newEntries.length > oldEntries.length){
delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED); delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED);
} else { } else {
ICSourceEntry newEntry; for (ICSourceEntry newEntry : newEntries) {
for(int i = 0; i < newEntries.length; i++){
boolean found = false; boolean found = false;
newEntry = newEntries[i]; for (ICSourceEntry oldEntry : oldEntries) {
for(int j = 0; j < oldEntries.length; j++){ if(newEntry.equals(oldEntry)){
if(newEntry.equals(oldEntries[j])){
found = true; found = true;
break; break;
} }
@ -1490,12 +1483,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(oldEntries.length > newEntries.length){ if(oldEntries.length > newEntries.length){
delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED); delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED);
} else { } else {
ICSourceEntry oldEntry; for (ICSourceEntry oldEntry : oldEntries) {
for(int i = 0; i < oldEntries.length; i++){
boolean found = false; boolean found = false;
oldEntry = oldEntries[i]; for (ICSourceEntry newEntry : newEntries) {
for(int j = 0; j < newEntries.length; j++){ if(oldEntry.equals(newEntry)){
if(oldEntry.equals(newEntries[j])){
found = true; found = true;
break; break;
} }
@ -1535,8 +1526,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
int flags = 0; int flags = 0;
int addedRemoved = ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED | ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED; int addedRemoved = ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED | ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED;
if(deltas != null ){ if(deltas != null ){
for(int i = 0; i < deltas.length; i++){ for (ExtSettingsDelta dt : deltas) {
ICSettingEntry[][] d = deltas[i].getEntriesDelta(); ICSettingEntry[][] d = dt.getEntriesDelta();
if(d[0] != null) if(d[0] != null)
flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED; flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED;
if(d[1] != null) if(d[1] != null)
@ -1609,20 +1600,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
List<ICLanguageSetting> oldList = new ArrayList<ICLanguageSetting>(Arrays.asList(oldLss)); List<ICLanguageSetting> oldList = new ArrayList<ICLanguageSetting>(Arrays.asList(oldLss));
List<ICLanguageSetting[]> matched = sortSettings(newList, oldList); List<ICLanguageSetting[]> matched = sortSettings(newList, oldList);
for(Iterator<ICLanguageSetting[]> iter = matched.iterator(); iter.hasNext();){ for (ICLanguageSetting[] match : matched) {
ICLanguageSetting[] match = iter.next();
CProjectDescriptionDelta lsDelta = createDelta(match[0], match[1]); CProjectDescriptionDelta lsDelta = createDelta(match[0], match[1]);
if(lsDelta != null) if(lsDelta != null)
delta.addChild(lsDelta); delta.addChild(lsDelta);
} }
for(Iterator<ICLanguageSetting> iter = newList.iterator(); iter.hasNext();){ for (ICLanguageSetting added : newList) {
ICLanguageSetting added = iter.next();
delta.addChild(createDelta(added, null)); delta.addChild(createDelta(added, null));
} }
for(Iterator<ICLanguageSetting> iter = oldList.iterator(); iter.hasNext();){ for (ICLanguageSetting removed : oldList) {
ICLanguageSetting removed = iter.next();
delta.addChild(createDelta(null, removed)); delta.addChild(createDelta(null, removed));
} }
@ -1766,12 +1754,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_ID); delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_ID);
int kinds[] = KindBasedStore.getLanguageEntryKinds(); int kinds[] = KindBasedStore.getLanguageEntryKinds();
int kind;
int addedKinds = 0; int addedKinds = 0;
int removedKinds = 0; int removedKinds = 0;
int reorderedKinds = 0; int reorderedKinds = 0;
for(int i = 0; i < kinds.length; i++){ for (int kind : kinds) {
kind = kinds[i];
ICLanguageSettingEntry newEntries[] = newLs.getSettingEntries(kind); ICLanguageSettingEntry newEntries[] = newLs.getSettingEntries(kind);
ICLanguageSettingEntry oldEntries[] = oldLs.getSettingEntries(kind); ICLanguageSettingEntry oldEntries[] = oldLs.getSettingEntries(kind);
boolean[] change = calculateSettingsChanges(newEntries, oldEntries); boolean[] change = calculateSettingsChanges(newEntries, oldEntries);
@ -1958,10 +1944,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
ICDescriptionDelta children[] = cfgDelta.getChildren(); ICDescriptionDelta children[] = cfgDelta.getChildren();
ICDescriptionDelta child;
int type; int type;
for(int i = 0; i < children.length; i++){ for (ICDescriptionDelta child : children) {
child = children[i];
type = child.getSettingType(); type = child.getSettingType();
if(type == ICSettingBase.SETTING_FILE || type == ICSettingBase.SETTING_FOLDER){ if(type == ICSettingBase.SETTING_FILE || type == ICSettingBase.SETTING_FOLDER){
generateCElementDeltasFromResourceDelta(cProject, child, list); generateCElementDeltasFromResourceDelta(cProject, child, list);
@ -2022,7 +2006,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
CElementDelta ceRcDelta = new CElementDelta(el.getCModel()); CElementDelta ceRcDelta = new CElementDelta(el.getCModel());
ceRcDelta.changed(el, ICElementDelta.F_MODIFIERS); ceRcDelta.changed(el, ICElementDelta.F_MODIFIERS);
list.add(ceRcDelta); list.add(ceRcDelta);
if(rc.getType() == IResource.FILE){ if(rc.getType() == IResource.FILE){
String fileName = path.lastSegment(); String fileName = path.lastSegment();
ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName); ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName);
@ -2035,13 +2019,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
return; return;
} }
ICFolderDescription newFoDes = (ICFolderDescription)newRcDes; ICFolderDescription newFoDes = (ICFolderDescription)newRcDes;
if(oldRcDes.getType() != ICSettingBase.SETTING_FOLDER){ if(oldRcDes.getType() != ICSettingBase.SETTING_FOLDER){
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+oldRcDes)); //$NON-NLS-1$ CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+oldRcDes)); //$NON-NLS-1$
return; return;
} }
ICFolderDescription oldFoDes = (ICFolderDescription)oldRcDes; ICFolderDescription oldFoDes = (ICFolderDescription)oldRcDes;
ICDescriptionDelta folderDelta = createDelta(newFoDes, oldFoDes); ICDescriptionDelta folderDelta = createDelta(newFoDes, oldFoDes);
if (folderDelta != null) { if (folderDelta != null) {
for (ICDescriptionDelta child : folderDelta.getChildren()) { for (ICDescriptionDelta child : folderDelta.getChildren()) {
@ -2082,25 +2066,25 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
int flags = 0; int flags = 0;
int kindsArray[] = kindsToArray(languageDeltaKinds); int kindsArray[] = kindsToArray(languageDeltaKinds);
for(int i = 0; i < kindsArray.length; i++){ for (int element : kindsArray) {
switch(kindsArray[i]){ switch(element){
case ICLanguageSettingEntry.INCLUDE_PATH: case ICSettingEntry.INCLUDE_PATH:
flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
break; break;
case ICLanguageSettingEntry.INCLUDE_FILE: case ICSettingEntry.INCLUDE_FILE:
flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
break; break;
case ICLanguageSettingEntry.MACRO: case ICSettingEntry.MACRO:
flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO; flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
break; break;
case ICLanguageSettingEntry.MACRO_FILE: case ICSettingEntry.MACRO_FILE:
flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO; flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
break; break;
case ICLanguageSettingEntry.LIBRARY_PATH: case ICSettingEntry.LIBRARY_PATH:
flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY
: ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY; : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
break; break;
case ICLanguageSettingEntry.LIBRARY_FILE: case ICSettingEntry.LIBRARY_FILE:
flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY
: ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY; : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
break; break;
@ -2113,9 +2097,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
int allKinds[] = KindBasedStore.getLanguageEntryKinds(); int allKinds[] = KindBasedStore.getLanguageEntryKinds();
int kindsArray[] = new int[allKinds.length]; int kindsArray[] = new int[allKinds.length];
int num = 0; int num = 0;
for(int i = 0; i < allKinds.length; i++){ for (int kind : allKinds) {
if((allKinds[i] & kinds) != 0){ if((kind & kinds) != 0){
kindsArray[num++] = allKinds[i]; kindsArray[num++] = kind;
} }
} }
@ -2153,9 +2137,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
return; return;
ICDescriptionDelta cfgDeltas[] = delta.getChildren(); ICDescriptionDelta cfgDeltas[] = delta.getChildren();
for(int i = 0; i < cfgDeltas.length; i++){ for (ICDescriptionDelta cfgDelta : cfgDeltas) {
if(cfgDeltas[i].getDeltaKind() == ICDescriptionDelta.REMOVED){ if(cfgDelta.getDeltaKind() == ICDescriptionDelta.REMOVED){
CConfigurationDescriptionCache des = (CConfigurationDescriptionCache)cfgDeltas[i].getOldSetting(); CConfigurationDescriptionCache des = (CConfigurationDescriptionCache)cfgDelta.getOldSetting();
CConfigurationData data = des.getConfigurationData(); CConfigurationData data = des.getConfigurationData();
try { try {
removeData(des, data, null); removeData(des, data, null);
@ -2303,8 +2287,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
if(el != null){ if(el != null){
ICStorageElement children[] = el.getChildren(); ICStorageElement children[] = el.getChildren();
for(int i = 0; i < children.length; i++){ for (ICStorageElement child : children) {
ICStorageElement child = children[i];
if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){ if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){
if(buildSystemId.equals(child.getAttribute(ID))){ if(buildSystemId.equals(child.getAttribute(ID))){
cfgEl = child; cfgEl = child;
@ -2329,8 +2312,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
ICStorageElement children[] = el.getChildren(); ICStorageElement children[] = el.getChildren();
ICStorageElement cfgEl = null; ICStorageElement cfgEl = null;
for(int i = 0; i < children.length; i++){ for (ICStorageElement child : children) {
ICStorageElement child = children[i];
if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){ if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){
if(buildSystemId.equals(child.getAttribute(ID))){ if(buildSystemId.equals(child.getAttribute(ID))){
cfgEl = child; cfgEl = child;
@ -2487,8 +2469,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
static private HashMap<HashSet<String>, CLanguageData> createExtSetToLDataMap(IProject project, CLanguageData[] lDatas){ static private HashMap<HashSet<String>, CLanguageData> createExtSetToLDataMap(IProject project, CLanguageData[] lDatas){
HashMap<HashSet<String>, CLanguageData> map = new HashMap<HashSet<String>, CLanguageData>(); HashMap<HashSet<String>, CLanguageData> map = new HashMap<HashSet<String>, CLanguageData>();
for(int i = 0; i < lDatas.length; i++){ for (CLanguageData lData : lDatas) {
CLanguageData lData = lDatas[i];
String[] exts = CDataUtil.getSourceExtensions(project, lData); String[] exts = CDataUtil.getSourceExtensions(project, lData);
HashSet<String> set = new HashSet<String>(Arrays.asList(exts)); HashSet<String> set = new HashSet<String>(Arrays.asList(exts));
map.put(set, lData); map.put(set, lData);
@ -2498,13 +2479,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
static boolean removeNonCustomSettings(IProject project, CConfigurationData data){ static boolean removeNonCustomSettings(IProject project, CConfigurationData data){
PathSettingsContainer cr = CDataUtil.createRcDataHolder(data); PathSettingsContainer cont = CDataUtil.createRcDataHolder(data);
PathSettingsContainer[] crs = cr.getChildren(false); PathSettingsContainer[] children = cont.getChildren(false);
PathSettingsContainer child, parent; PathSettingsContainer parent;
CResourceData childRcData; CResourceData childRcData;
boolean modified = false; boolean modified = false;
for(int i = 0; i < crs.length; i++){ for (PathSettingsContainer child : children) {
child = crs[i];
childRcData = (CResourceData)child.getValue(); childRcData = (CResourceData)child.getValue();
if(childRcData.getType() == ICSettingBase.SETTING_FOLDER){ if(childRcData.getType() == ICSettingBase.SETTING_FOLDER){
CResourceData parentRcData = null; CResourceData parentRcData = null;
@ -2599,9 +2579,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
return false; return false;
int kinds[] = KindBasedStore.getLanguageEntryKinds(); int kinds[] = KindBasedStore.getLanguageEntryKinds();
int kind; for (int kind : kinds) {
for(int i = 0; i < kinds.length; i++){
kind = kinds[i];
ICLanguageSettingEntry entries1[] = lData1.getEntries(kind); ICLanguageSettingEntry entries1[] = lData1.getEntries(kind);
ICLanguageSettingEntry entries2[] = lData2.getEntries(kind); ICLanguageSettingEntry entries2[] = lData2.getEntries(kind);
if(!Arrays.equals(entries1, entries2)) if(!Arrays.equals(entries1, entries2))
@ -2703,9 +2681,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
private ICStorageElement getCProjectDescriptionPreferencesElement(boolean createIfNotFound, boolean readOnly) throws CoreException{ private ICStorageElement getCProjectDescriptionPreferencesElement(boolean createIfNotFound, boolean readOnly) throws CoreException{
ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotFound, readOnly); ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotFound, readOnly);
ICStorageElement[] children = el.getChildren(); ICStorageElement[] children = el.getChildren();
for(int i = 0; i < children.length; i++){ for (ICStorageElement child : children) {
if(PREFERENCES_ELEMENT.equals(children[i].getName())) if(PREFERENCES_ELEMENT.equals(child.getName()))
return children[i]; return child;
} }
if(createIfNotFound) if(createIfNotFound)
return el.createChild(PREFERENCES_ELEMENT); return el.createChild(PREFERENCES_ELEMENT);