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

cosmetics: enhanced loops etc

This commit is contained in:
Andrew Gvozdev 2010-01-24 22:25:56 +00:00
parent 257f512b69
commit 37c2c68fbd

View file

@ -45,21 +45,21 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
private List<IPathEntryStoreListener> fListeners;
private IProject fProject;
static final QualifiedName PATH_ENTRY_COLLECTOR_PROPERTY_NAME = new QualifiedName(CCorePlugin.PLUGIN_ID, "PathEntryStoreCollector"); //$NON-NLS-1$
/**
*
*
*/
public ConfigBasedPathEntryStore(IProject project) {
fProject = project;
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADED);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/
public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
fListeners.add(listener);
}
@ -74,8 +74,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
fListeners.toArray(observers);
for (int i = 0; i < observers.length; i++) {
observers[i].pathEntryStoreChanged(evt);
for (IPathEntryStoreListener observer : observers) {
observer.pathEntryStoreChanged(evt);
}
}
@ -86,8 +86,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
fListeners.toArray(observers);
for (int i = 0; i < observers.length; i++) {
observers[i].pathEntryStoreChanged(evt);
for (IPathEntryStoreListener observer : observers) {
observer.pathEntryStoreChanged(evt);
}
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
}
@ -119,11 +119,11 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
List<IPathEntry> sysList = es[1];
List<IPathEntry> usrList = es[0];
List<IPathEntry> newUsrList = new ArrayList<IPathEntry>(entries.length);
for(int i = 0; i < entries.length; i++){
if(entries[i].getEntryKind() != IPathEntry.CDT_CONTAINER)
newUsrList.add(entries[i]);
for (IPathEntry entry : entries) {
if(entry.getEntryKind() != IPathEntry.CDT_CONTAINER)
newUsrList.add(entry);
}
if(!newUsrList.equals(usrList)){
usrList = newUsrList;
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(fProject, true);
@ -135,25 +135,24 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
ReferenceSettingsInfo rInfo = tr.applyPathEntries(usrEntries, sysEntries, PathEntryTranslator.OP_REPLACE);
cfgDes.removeExternalSettings();
ICExternalSetting extSettings[] = rInfo.getExternalSettings();
for(int i = 0; i < extSettings.length; i++){
ICExternalSetting setting = extSettings[i];
cfgDes.createExternalSetting(setting.getCompatibleLanguageIds(),
for (ICExternalSetting setting : extSettings) {
cfgDes.createExternalSetting(setting.getCompatibleLanguageIds(),
setting.getCompatibleContentTypeIds(),
setting.getCompatibleExtensions(),
setting.getCompatibleExtensions(),
setting.getEntries());
}
Map<String, String> refMap = rInfo.getRefProjectsMap();
cfgDes.setReferenceInfo(refMap);
CoreModel.getDefault().setProjectDescription(fProject, des);
}
}
}
private static void clearCachedEntries(ICProjectDescription des){
ICConfigurationDescription[] cfgDess = des.getConfigurations();
for(int i = 0; i < cfgDess.length; i++){
setCachedEntries(cfgDess[i], null);
for (ICConfigurationDescription cfgDes : cfgDess) {
setCachedEntries(cfgDes, null);
}
}
@ -161,7 +160,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
IProject project = event.getProject();
if(!fProject.equals(project))
return;
switch(event.getEventType()){
case CProjectDescriptionEvent.APPLIED:{
ICProjectDescription des = event.getNewCProjectDescription();
@ -172,13 +171,13 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
List<IPathEntry>[] oldEs = getCachedEntries(oldIndexCfg);
if(oldEs != null)
oldCrEntries = oldEs[1];
clearCachedEntries(oldDes);
}
if(des != null){
//TODO: smart delta handling
clearCachedEntries(des);
if(oldCrEntries != null){
ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration();
List<IPathEntry>[] newEs = getEntries(fProject, newIndexCfg);
@ -186,7 +185,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){
CModelManager manager = CModelManager.getDefault();
ICProject cproject = manager.create(project);
// ConfigBasedPathEntryContainer newContainer = createContainer(des);
try {
@ -202,7 +201,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
}
}
}
// private static PathEntryCollector getCollector(ICProjectDescription des){
// ICConfigurationDescription cfgDes = ((CProjectDescription)des).getIndexConfiguration();
// if(cfgDes != null){
@ -228,16 +227,16 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
}
return null;
}
private static List<IPathEntry>[] createEntriesList(ICConfigurationDescription cfgDes, PathEntryCollector cr){
ArrayList<IPathEntry>[] es = new ArrayList[2];
es[0] = new ArrayList<IPathEntry>();
es[0] = new ArrayList<IPathEntry>();
cr.getEntries(es[0], PathEntryTranslator.INCLUDE_USER, cfgDes);
es[0].trimToSize();
es[1] = new ArrayList<IPathEntry>();
es[1] = new ArrayList<IPathEntry>();
cr.getEntries(es[1], PathEntryTranslator.INCLUDE_BUILT_INS, cfgDes);
es[1].trimToSize();
return es;
}
@ -256,12 +255,12 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
// return getCollector(des);
// return null;
// }
private static ICConfigurationDescription getIndexCfg(IProject project){
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
return des != null ? des.getDefaultSettingConfiguration() : null;
}
private static List<IPathEntry> getContainerEntries(IProject project){
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
if(des != null)