diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java index 00e3b6a980e..afa34d6532e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2010 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.QualifiedName; public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDescriptionListener { - private List fListeners; + private List fListeners; private IProject fProject; static final QualifiedName PATH_ENTRY_COLLECTOR_PROPERTY_NAME = new QualifiedName(CCorePlugin.PLUGIN_ID, "PathEntryStoreCollector"); //$NON-NLS-1$ @@ -51,7 +51,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc */ public ConfigBasedPathEntryStore(IProject project) { fProject = project; - fListeners = Collections.synchronizedList(new ArrayList()); + fListeners = Collections.synchronizedList(new ArrayList()); CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADED); } @@ -102,23 +102,23 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc public IPathEntry[] getRawPathEntries() throws CoreException { ICConfigurationDescription cfg = getIndexCfg(fProject); - List[] es = getEntries(fProject, cfg); + List[] es = getEntries(fProject, cfg); if(es != null){ - List list = new ArrayList(es[0].size() + 1); + List list = new ArrayList(es[0].size() + 1); list.addAll(es[0]); list.add(CoreModel.newContainerEntry(ConfigBasedPathEntryContainer.CONTAINER_PATH)); - return (IPathEntry[])list.toArray(new IPathEntry[list.size()]); + return list.toArray(new IPathEntry[list.size()]); } return new IPathEntry[0]; } public void setRawPathEntries(IPathEntry[] entries) throws CoreException { ICConfigurationDescription cfg = getIndexCfg(fProject); - List es[] = getEntries(fProject, cfg); + List es[] = getEntries(fProject, cfg); if(es != null){ - List sysList = es[1]; - List usrList = es[0]; - List newUsrList = new ArrayList(entries.length); + List sysList = es[1]; + List usrList = es[0]; + List newUsrList = new ArrayList(entries.length); for(int i = 0; i < entries.length; i++){ if(entries[i].getEntryKind() != IPathEntry.CDT_CONTAINER) newUsrList.add(entries[i]); @@ -130,8 +130,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration(); CConfigurationData data = cfgDes.getConfigurationData(); PathEntryTranslator tr = new PathEntryTranslator(fProject, data); - IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]); - IPathEntry[] sysEntries = (IPathEntry[])sysList.toArray(new IPathEntry[sysList.size()]); + IPathEntry[] usrEntries = usrList.toArray(new IPathEntry[usrList.size()]); + IPathEntry[] sysEntries = sysList.toArray(new IPathEntry[sysList.size()]); ReferenceSettingsInfo rInfo = tr.applyPathEntries(usrEntries, sysEntries, PathEntryTranslator.OP_REPLACE); cfgDes.removeExternalSettings(); ICExternalSetting extSettings[] = rInfo.getExternalSettings(); @@ -142,7 +142,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc setting.getCompatibleExtensions(), setting.getEntries()); } - Map refMap = rInfo.getRefProjectsMap(); + Map refMap = rInfo.getRefProjectsMap(); cfgDes.setReferenceInfo(refMap); CoreModel.getDefault().setProjectDescription(fProject, des); @@ -166,10 +166,10 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc case CProjectDescriptionEvent.APPLIED:{ ICProjectDescription des = event.getNewCProjectDescription(); ICProjectDescription oldDes = event.getOldCProjectDescription(); - List oldCrEntries = null; + List oldCrEntries = null; if(oldDes != null){ ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration(); - List[] oldEs = getCachedEntries(oldIndexCfg); + List[] oldEs = getCachedEntries(oldIndexCfg); if(oldEs != null) oldCrEntries = oldEs[1]; @@ -181,8 +181,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc if(oldCrEntries != null){ ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration(); - List[] newEs = getEntries(fProject, newIndexCfg); - List newCrEntries = newEs[1]; + List[] newEs = getEntries(fProject, newIndexCfg); + List newCrEntries = newEs[1]; if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){ CModelManager manager = CModelManager.getDefault(); ICProject cproject = manager.create(project); @@ -216,9 +216,9 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc // return null; // } - private static List[] getEntries(IProject project, ICConfigurationDescription cfgDes){ + private static List[] getEntries(IProject project, ICConfigurationDescription cfgDes){ if(cfgDes != null){ - List[] es = getCachedEntries(cfgDes); + List[] es = getCachedEntries(cfgDes); if(es == null){ PathEntryCollector cr = PathEntryTranslator.collectEntries(project, cfgDes); es = createEntriesList(cfgDes, cr); @@ -229,23 +229,24 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc return null; } - private static List[] createEntriesList(ICConfigurationDescription cfgDes, PathEntryCollector cr){ - ArrayList[] es = new ArrayList[2]; - es[0] = new ArrayList(); + private static List[] createEntriesList(ICConfigurationDescription cfgDes, PathEntryCollector cr){ + ArrayList[] es = new ArrayList[2]; + es[0] = new ArrayList(); cr.getEntries(es[0], PathEntryTranslator.INCLUDE_USER, cfgDes); es[0].trimToSize(); - es[1] = new ArrayList(); + es[1] = new ArrayList(); cr.getEntries(es[1], PathEntryTranslator.INCLUDE_BUILT_INS, cfgDes); es[1].trimToSize(); return es; } - private static List[] getCachedEntries(ICConfigurationDescription cfgDes){ - return (List[])cfgDes.getSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME); + @SuppressWarnings("unchecked") + private static List[] getCachedEntries(ICConfigurationDescription cfgDes){ + return (List[])cfgDes.getSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME); } - private static void setCachedEntries(ICConfigurationDescription cfgDes, List[] es){ + private static void setCachedEntries(ICConfigurationDescription cfgDes, List[] es){ cfgDes.setSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME, es); } @@ -261,28 +262,28 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc return des != null ? des.getDefaultSettingConfiguration() : null; } - private static List getContainerEntries(IProject project){ + private static List getContainerEntries(IProject project){ ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false); if(des != null) return getContainerEntries(des); - return new ArrayList(0); + return new ArrayList(0); } - private static List getContainerEntries(ICProjectDescription des){ + private static List getContainerEntries(ICProjectDescription des){ ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); - List es[] = getEntries(des.getProject(), cfg); + List es[] = getEntries(des.getProject(), cfg); if(es != null) return es[1]; - return new ArrayList(0); + return new ArrayList(0); } public static ConfigBasedPathEntryContainer createContainer(IProject project){ - List list = getContainerEntries(project); + List list = getContainerEntries(project); return new ConfigBasedPathEntryContainer(list); } public static ConfigBasedPathEntryContainer createContainer(ICProjectDescription des){ - List list = getContainerEntries(des); + List list = getContainerEntries(des); return new ConfigBasedPathEntryContainer(list); } }