mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
cosmetics: generics
This commit is contained in:
parent
1bb19098d3
commit
257f512b69
1 changed files with 34 additions and 33 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -42,7 +42,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDescriptionListener {
|
public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDescriptionListener {
|
||||||
private List fListeners;
|
private List<IPathEntryStoreListener> fListeners;
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
static final QualifiedName PATH_ENTRY_COLLECTOR_PROPERTY_NAME = new QualifiedName(CCorePlugin.PLUGIN_ID, "PathEntryStoreCollector"); //$NON-NLS-1$
|
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) {
|
public ConfigBasedPathEntryStore(IProject project) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fListeners = Collections.synchronizedList(new ArrayList());
|
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
|
||||||
|
|
||||||
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADED);
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADED);
|
||||||
}
|
}
|
||||||
|
@ -102,23 +102,23 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
|
|
||||||
public IPathEntry[] getRawPathEntries() throws CoreException {
|
public IPathEntry[] getRawPathEntries() throws CoreException {
|
||||||
ICConfigurationDescription cfg = getIndexCfg(fProject);
|
ICConfigurationDescription cfg = getIndexCfg(fProject);
|
||||||
List[] es = getEntries(fProject, cfg);
|
List<IPathEntry>[] es = getEntries(fProject, cfg);
|
||||||
if(es != null){
|
if(es != null){
|
||||||
List list = new ArrayList(es[0].size() + 1);
|
List<IPathEntry> list = new ArrayList<IPathEntry>(es[0].size() + 1);
|
||||||
list.addAll(es[0]);
|
list.addAll(es[0]);
|
||||||
list.add(CoreModel.newContainerEntry(ConfigBasedPathEntryContainer.CONTAINER_PATH));
|
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];
|
return new IPathEntry[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
|
public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
|
||||||
ICConfigurationDescription cfg = getIndexCfg(fProject);
|
ICConfigurationDescription cfg = getIndexCfg(fProject);
|
||||||
List es[] = getEntries(fProject, cfg);
|
List<IPathEntry> es[] = getEntries(fProject, cfg);
|
||||||
if(es != null){
|
if(es != null){
|
||||||
List sysList = es[1];
|
List<IPathEntry> sysList = es[1];
|
||||||
List usrList = es[0];
|
List<IPathEntry> usrList = es[0];
|
||||||
List newUsrList = new ArrayList(entries.length);
|
List<IPathEntry> newUsrList = new ArrayList<IPathEntry>(entries.length);
|
||||||
for(int i = 0; i < entries.length; i++){
|
for(int i = 0; i < entries.length; i++){
|
||||||
if(entries[i].getEntryKind() != IPathEntry.CDT_CONTAINER)
|
if(entries[i].getEntryKind() != IPathEntry.CDT_CONTAINER)
|
||||||
newUsrList.add(entries[i]);
|
newUsrList.add(entries[i]);
|
||||||
|
@ -130,8 +130,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration();
|
ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration();
|
||||||
CConfigurationData data = cfgDes.getConfigurationData();
|
CConfigurationData data = cfgDes.getConfigurationData();
|
||||||
PathEntryTranslator tr = new PathEntryTranslator(fProject, data);
|
PathEntryTranslator tr = new PathEntryTranslator(fProject, data);
|
||||||
IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]);
|
IPathEntry[] usrEntries = usrList.toArray(new IPathEntry[usrList.size()]);
|
||||||
IPathEntry[] sysEntries = (IPathEntry[])sysList.toArray(new IPathEntry[sysList.size()]);
|
IPathEntry[] sysEntries = sysList.toArray(new IPathEntry[sysList.size()]);
|
||||||
ReferenceSettingsInfo rInfo = tr.applyPathEntries(usrEntries, sysEntries, PathEntryTranslator.OP_REPLACE);
|
ReferenceSettingsInfo rInfo = tr.applyPathEntries(usrEntries, sysEntries, PathEntryTranslator.OP_REPLACE);
|
||||||
cfgDes.removeExternalSettings();
|
cfgDes.removeExternalSettings();
|
||||||
ICExternalSetting extSettings[] = rInfo.getExternalSettings();
|
ICExternalSetting extSettings[] = rInfo.getExternalSettings();
|
||||||
|
@ -142,7 +142,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
setting.getCompatibleExtensions(),
|
setting.getCompatibleExtensions(),
|
||||||
setting.getEntries());
|
setting.getEntries());
|
||||||
}
|
}
|
||||||
Map refMap = rInfo.getRefProjectsMap();
|
Map<String, String> refMap = rInfo.getRefProjectsMap();
|
||||||
cfgDes.setReferenceInfo(refMap);
|
cfgDes.setReferenceInfo(refMap);
|
||||||
|
|
||||||
CoreModel.getDefault().setProjectDescription(fProject, des);
|
CoreModel.getDefault().setProjectDescription(fProject, des);
|
||||||
|
@ -166,10 +166,10 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
case CProjectDescriptionEvent.APPLIED:{
|
case CProjectDescriptionEvent.APPLIED:{
|
||||||
ICProjectDescription des = event.getNewCProjectDescription();
|
ICProjectDescription des = event.getNewCProjectDescription();
|
||||||
ICProjectDescription oldDes = event.getOldCProjectDescription();
|
ICProjectDescription oldDes = event.getOldCProjectDescription();
|
||||||
List oldCrEntries = null;
|
List<IPathEntry> oldCrEntries = null;
|
||||||
if(oldDes != null){
|
if(oldDes != null){
|
||||||
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
List[] oldEs = getCachedEntries(oldIndexCfg);
|
List<IPathEntry>[] oldEs = getCachedEntries(oldIndexCfg);
|
||||||
if(oldEs != null)
|
if(oldEs != null)
|
||||||
oldCrEntries = oldEs[1];
|
oldCrEntries = oldEs[1];
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
|
|
||||||
if(oldCrEntries != null){
|
if(oldCrEntries != null){
|
||||||
ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration();
|
ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration();
|
||||||
List[] newEs = getEntries(fProject, newIndexCfg);
|
List<IPathEntry>[] newEs = getEntries(fProject, newIndexCfg);
|
||||||
List newCrEntries = newEs[1];
|
List<IPathEntry> newCrEntries = newEs[1];
|
||||||
if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){
|
if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){
|
||||||
CModelManager manager = CModelManager.getDefault();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
ICProject cproject = manager.create(project);
|
ICProject cproject = manager.create(project);
|
||||||
|
@ -216,9 +216,9 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static List[] getEntries(IProject project, ICConfigurationDescription cfgDes){
|
private static List<IPathEntry>[] getEntries(IProject project, ICConfigurationDescription cfgDes){
|
||||||
if(cfgDes != null){
|
if(cfgDes != null){
|
||||||
List[] es = getCachedEntries(cfgDes);
|
List<IPathEntry>[] es = getCachedEntries(cfgDes);
|
||||||
if(es == null){
|
if(es == null){
|
||||||
PathEntryCollector cr = PathEntryTranslator.collectEntries(project, cfgDes);
|
PathEntryCollector cr = PathEntryTranslator.collectEntries(project, cfgDes);
|
||||||
es = createEntriesList(cfgDes, cr);
|
es = createEntriesList(cfgDes, cr);
|
||||||
|
@ -229,23 +229,24 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List[] createEntriesList(ICConfigurationDescription cfgDes, PathEntryCollector cr){
|
private static List<IPathEntry>[] createEntriesList(ICConfigurationDescription cfgDes, PathEntryCollector cr){
|
||||||
ArrayList[] es = new ArrayList[2];
|
ArrayList<IPathEntry>[] es = new ArrayList[2];
|
||||||
es[0] = new ArrayList();
|
es[0] = new ArrayList<IPathEntry>();
|
||||||
cr.getEntries(es[0], PathEntryTranslator.INCLUDE_USER, cfgDes);
|
cr.getEntries(es[0], PathEntryTranslator.INCLUDE_USER, cfgDes);
|
||||||
es[0].trimToSize();
|
es[0].trimToSize();
|
||||||
es[1] = new ArrayList();
|
es[1] = new ArrayList<IPathEntry>();
|
||||||
cr.getEntries(es[1], PathEntryTranslator.INCLUDE_BUILT_INS, cfgDes);
|
cr.getEntries(es[1], PathEntryTranslator.INCLUDE_BUILT_INS, cfgDes);
|
||||||
es[1].trimToSize();
|
es[1].trimToSize();
|
||||||
|
|
||||||
return es;
|
return es;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List[] getCachedEntries(ICConfigurationDescription cfgDes){
|
@SuppressWarnings("unchecked")
|
||||||
return (List[])cfgDes.getSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME);
|
private static List<IPathEntry>[] getCachedEntries(ICConfigurationDescription cfgDes){
|
||||||
|
return (List<IPathEntry>[])cfgDes.getSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCachedEntries(ICConfigurationDescription cfgDes, List[] es){
|
private static void setCachedEntries(ICConfigurationDescription cfgDes, List<IPathEntry>[] es){
|
||||||
cfgDes.setSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME, 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;
|
return des != null ? des.getDefaultSettingConfiguration() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List getContainerEntries(IProject project){
|
private static List<IPathEntry> getContainerEntries(IProject project){
|
||||||
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
|
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
|
||||||
if(des != null)
|
if(des != null)
|
||||||
return getContainerEntries(des);
|
return getContainerEntries(des);
|
||||||
return new ArrayList(0);
|
return new ArrayList<IPathEntry>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List getContainerEntries(ICProjectDescription des){
|
private static List<IPathEntry> getContainerEntries(ICProjectDescription des){
|
||||||
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
List es[] = getEntries(des.getProject(), cfg);
|
List<IPathEntry> es[] = getEntries(des.getProject(), cfg);
|
||||||
if(es != null)
|
if(es != null)
|
||||||
return es[1];
|
return es[1];
|
||||||
return new ArrayList(0);
|
return new ArrayList<IPathEntry>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigBasedPathEntryContainer createContainer(IProject project){
|
public static ConfigBasedPathEntryContainer createContainer(IProject project){
|
||||||
List list = getContainerEntries(project);
|
List<IPathEntry> list = getContainerEntries(project);
|
||||||
return new ConfigBasedPathEntryContainer(list);
|
return new ConfigBasedPathEntryContainer(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigBasedPathEntryContainer createContainer(ICProjectDescription des){
|
public static ConfigBasedPathEntryContainer createContainer(ICProjectDescription des){
|
||||||
List list = getContainerEntries(des);
|
List<IPathEntry> list = getContainerEntries(des);
|
||||||
return new ConfigBasedPathEntryContainer(list);
|
return new ConfigBasedPathEntryContainer(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue