1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

cosmetics: generics/enhanced loops

This commit is contained in:
Andrew Gvozdev 2010-01-25 15:47:23 +00:00
parent f3bd8f6e30
commit d0ef57bff8

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 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
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.settings.model;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -45,7 +44,7 @@ import org.eclipse.core.runtime.QualifiedName;
/** /**
* CConfigurationSpecSettings impelements ICSettingsStorage * CConfigurationSpecSettings impelements ICSettingsStorage
* to provide storage for ICStorageElements related to project settings * to provide storage for ICStorageElements related to project settings
* *
* This corresponds to the <cconfiguration id="....> elements within * This corresponds to the <cconfiguration id="....> elements within
* the org.eclipse.cdt.core.settings storageModule in the project xml file * the org.eclipse.cdt.core.settings storageModule in the project xml file
*/ */
@ -87,21 +86,21 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
private COwner fOwner; private COwner fOwner;
// private CConfigBasedDescriptor fDescriptor; // private CConfigBasedDescriptor fDescriptor;
// private Map fExternalSettingsProviderMap; // private Map fExternalSettingsProviderMap;
public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage) throws CoreException{ public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage) throws CoreException{
fCfg = des; fCfg = des;
fRootStorageElement = storage; fRootStorageElement = storage;
ICStorageElement settings = getSettingsStorageElement(); ICStorageElement settings = getSettingsStorageElement();
fBuildSystemId = settings.getAttribute(BUILD_SYSTEM_ID); fBuildSystemId = settings.getAttribute(BUILD_SYSTEM_ID);
fName = settings.getAttribute(NAME); fName = settings.getAttribute(NAME);
fId = settings.getAttribute(ID); fId = settings.getAttribute(ID);
setCOwner(settings.getAttribute(OWNER_ID)); setCOwner(settings.getAttribute(OWNER_ID));
for (ICStorageElement child : settings.getChildren()) { for (ICStorageElement child : settings.getChildren()) {
String name = child.getName(); String name = child.getName();
if(StorableCdtVariables.MACROS_ELEMENT_NAME.equals(name)){ if(StorableCdtVariables.MACROS_ELEMENT_NAME.equals(name)){
fMacros = new StorableCdtVariables(child, fCfg.isReadOnly()); fMacros = new StorableCdtVariables(child, fCfg.isReadOnly());
}/* else if(ELEMENT_REFERENCES.equals(name)){ }/* else if(ELEMENT_REFERENCES.equals(name)){
@ -114,19 +113,19 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
loadExtensionInfo(child, false); loadExtensionInfo(child, false);
} }
} }
// if(fMacros == null) // if(fMacros == null)
// fMacros = new StorableMacros(des.isReadOnly()); // fMacros = new StorableMacros(des.isReadOnly());
} }
public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage, ICStorageElement oldInfo) throws CoreException{ public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage, ICStorageElement oldInfo) throws CoreException{
fCfg = des; fCfg = des;
fRootStorageElement = storage; fRootStorageElement = storage;
loadOldStileDescription(oldInfo); loadOldStileDescription(oldInfo);
} }
private void loadOldStileDescription(ICStorageElement storage) throws CoreException{ private void loadOldStileDescription(ICStorageElement storage) throws CoreException{
setCOwner(storage.getAttribute(OLD_OWNER_ID)); setCOwner(storage.getAttribute(OLD_OWNER_ID));
@ -149,33 +148,36 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fBuildSystemId = base.fBuildSystemId; fBuildSystemId = base.fBuildSystemId;
fName = base.fName; fName = base.fName;
fId = base.fId; fId = base.fId;
// copyRefInfos(base.fRefInfoMap); // copyRefInfos(base.fRefInfoMap);
if(base.fMacros != null) if(base.fMacros != null)
fMacros = new StorableCdtVariables(base.fMacros, des.isReadOnly()); fMacros = new StorableCdtVariables(base.fMacros, des.isReadOnly());
if(base.fExtSettingsProvider != null) if(base.fExtSettingsProvider != null)
fExtSettingsProvider = new CExternalSettingsHolder(base.fExtSettingsProvider); fExtSettingsProvider = new CExternalSettingsHolder(base.fExtSettingsProvider);
if(base.fSessionPropertiesMap != null) if(base.fSessionPropertiesMap != null) {
fSessionPropertiesMap = (HashMap<QualifiedName, Object>)base.fSessionPropertiesMap.clone(); @SuppressWarnings("unchecked")
HashMap<QualifiedName, Object> clone = (HashMap<QualifiedName, Object>)base.fSessionPropertiesMap.clone();
fSessionPropertiesMap = clone;
}
if(base.fEnvironment != null) if(base.fEnvironment != null)
fEnvironment = EnvironmentVariableManager.fUserSupplier.cloneEnvironmentWithContext(fCfg, base.fEnvironment, des.isReadOnly()); fEnvironment = EnvironmentVariableManager.fUserSupplier.cloneEnvironmentWithContext(fCfg, base.fEnvironment, des.isReadOnly());
fOwnerId = base.fOwnerId; fOwnerId = base.fOwnerId;
fOwner = base.fOwner; fOwner = base.fOwner;
copyExtensionInfo(base); copyExtensionInfo(base);
} }
// private void copyRefInfos(Map infosMap){ // private void copyRefInfos(Map infosMap){
// if(infosMap == null || infosMap.size() == 0){ // if(infosMap == null || infosMap.size() == 0){
// fRefInfoMap = null; // fRefInfoMap = null;
// return; // return;
// } // }
// //
// fRefInfoMap = new HashMap(infosMap.size()); // fRefInfoMap = new HashMap(infosMap.size());
// for(Iterator iter = infosMap.entrySet().iterator(); iter.hasNext();){ // for(Iterator iter = infosMap.entrySet().iterator(); iter.hasNext();){
// Map.Entry entry = (Map.Entry)iter.next(); // Map.Entry entry = (Map.Entry)iter.next();
@ -184,23 +186,24 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// fRefInfoMap.put(projName, new ProjectRefInfo(info)); // fRefInfoMap.put(projName, new ProjectRefInfo(info));
// } // }
// } // }
public void setCOwner(String ownerId) throws CoreException{ public void setCOwner(String ownerId) throws CoreException{
if(ownerId == null) if(ownerId == null)
ownerId = CConfigBasedDescriptorManager.NULL_OWNER_ID; ownerId = CConfigBasedDescriptorManager.NULL_OWNER_ID;
if(ownerId.equals(fOwnerId)) if(ownerId.equals(fOwnerId))
return; return;
fOwnerId = ownerId; fOwnerId = ownerId;
COwnerConfiguration cfg = CProjectDescriptionManager.getInstance().getDescriptorManager().getOwnerConfiguration(fOwnerId); CProjectDescriptionManager.getInstance().getDescriptorManager();
COwnerConfiguration cfg = CConfigBasedDescriptorManager.getOwnerConfiguration(fOwnerId);
fOwner = new COwner(cfg); fOwner = new COwner(cfg);
} }
// private void loadReferences(ICStorageElement el){ // private void loadReferences(ICStorageElement el){
// fRefInfoMap = new HashMap(); // fRefInfoMap = new HashMap();
// ICStorageElement children[] = el.getChildren(); // ICStorageElement children[] = el.getChildren();
// //
// for(int i = 0; i < children.length; i++){ // for(int i = 0; i < children.length; i++){
// ICStorageElement child = children[i]; // ICStorageElement child = children[i];
// String name = child.getName(); // String name = child.getName();
@ -210,11 +213,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// fRefInfoMap.put(info.getProjectName(), info); // fRefInfoMap.put(info.getProjectName(), info);
// } // }
// } // }
// //
// if(fRefInfoMap.size() == 0) // if(fRefInfoMap.size() == 0)
// fRefInfoMap = null; // fRefInfoMap = null;
// } // }
// private Map normalizeRefs(Map ref){ // private Map normalizeRefs(Map ref){
// for(Iterator iter = ref.entrySet().iterator(); iter.hasNext();){ // for(Iterator iter = ref.entrySet().iterator(); iter.hasNext();){
// Map.Entry entry = (Map.Entry)iter.next(); // Map.Entry entry = (Map.Entry)iter.next();
@ -225,9 +228,9 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// String cfg = (String)cfgObj; // String cfg = (String)cfgObj;
// if(cfg == null) // if(cfg == null)
// cfg = EMPTY_STRING; // cfg = EMPTY_STRING;
// else // else
// cfg = cfg.trim(); // cfg = cfg.trim();
// //
// if(proj.length() > 0){ // if(proj.length() > 0){
// entry.setValue(cfg); // entry.setValue(cfg);
// } else { // } else {
@ -243,9 +246,9 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// return null; // return null;
// if(cfgId == null) // if(cfgId == null)
// cfgId = EMPTY_STRING; // cfgId = EMPTY_STRING;
// else // else
// cfgId = cfgId.trim(); // cfgId = cfgId.trim();
// //
// return new String[] {projName, cfgId}; // return new String[] {projName, cfgId};
// } // }
@ -254,11 +257,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fSettingsStorageElement = getStorage(CProjectDescriptionManager.MODULE_ID, true); fSettingsStorageElement = getStorage(CProjectDescriptionManager.MODULE_ID, true);
return fSettingsStorageElement; return fSettingsStorageElement;
} }
public ICStorageElement getStorage(String id,boolean create) throws CoreException { public ICStorageElement getStorage(String id,boolean create) throws CoreException {
return getStorageBase().getStorage(id, create); return getStorageBase().getStorage(id, create);
} }
public void removeStorage(String id) throws CoreException { public void removeStorage(String id) throws CoreException {
getStorageBase().removeStorage(id); getStorageBase().removeStorage(id);
} }
@ -273,7 +276,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
return fRootStorageElement; return fRootStorageElement;
} }
void removeConfiguration() throws CoreException{ void removeConfiguration() throws CoreException{
CProjectDescriptionManager.getInstance().removeStorage(fCfg.getProjectDescription(), fCfg.getId()); CProjectDescriptionManager.getInstance().removeStorage(fCfg.getProjectDescription(), fCfg.getId());
} }
@ -285,24 +288,24 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fStorage = CProjectDescriptionManager.getInstance().getStorageForElement(null, getRootStorageElement()); fStorage = CProjectDescriptionManager.getInstance().getStorageForElement(null, getRootStorageElement());
else else
fStorage = CProjectDescriptionManager.getInstance().getStorageForElement(fCfg.getProjectDescription().getProject(), getRootStorageElement()); fStorage = CProjectDescriptionManager.getInstance().getStorageForElement(fCfg.getProjectDescription().getProject(), getRootStorageElement());
return fStorage; return fStorage;
} }
void doneInitialization(){ void doneInitialization(){
if(isReadOnly()) if(isReadOnly())
if(fStorage != null) if(fStorage != null)
fStorage.setReadOnly(true, false); fStorage.setReadOnly(true, false);
} }
public String getBuildSystemId(){ public String getBuildSystemId(){
return fBuildSystemId; return fBuildSystemId;
} }
public ICConfigurationDescription getConfigurarion(){ public ICConfigurationDescription getConfigurarion(){
return fCfg; return fCfg;
} }
public String getName() { public String getName() {
return fName; return fName;
} }
@ -315,7 +318,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fIsModified = true; fIsModified = true;
} }
} }
public String getId() { public String getId() {
return fId; return fId;
} }
@ -328,7 +331,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fIsModified = true; fIsModified = true;
} }
} }
void setBuildSystemId(String id){ void setBuildSystemId(String id){
if(isReadOnly()) if(isReadOnly())
throw ExceptionFactory.createIsReadOnlyException(); throw ExceptionFactory.createIsReadOnlyException();
@ -337,7 +340,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fIsModified = true; fIsModified = true;
} }
} }
void serializeId() throws CoreException { void serializeId() throws CoreException {
fId = fCfg.getId(); fId = fCfg.getId();
ICStorageElement settings = getSettingsStorageElement(); ICStorageElement settings = getSettingsStorageElement();
@ -349,21 +352,21 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fName = fCfg.getName(); fName = fCfg.getName();
ICStorageElement settings = getSettingsStorageElement(); ICStorageElement settings = getSettingsStorageElement();
settings.clear(); settings.clear();
settings.setAttribute(ID, fId); settings.setAttribute(ID, fId);
settings.setAttribute(NAME, fName); settings.setAttribute(NAME, fName);
settings.setAttribute(BUILD_SYSTEM_ID, fBuildSystemId); settings.setAttribute(BUILD_SYSTEM_ID, fBuildSystemId);
if(fMacros != null && !fMacros.isEmpty()){ if(fMacros != null && !fMacros.isEmpty()){
ICStorageElement macrosEl = settings.createChild(StorableCdtVariables.MACROS_ELEMENT_NAME); ICStorageElement macrosEl = settings.createChild(StorableCdtVariables.MACROS_ELEMENT_NAME);
fMacros.serialize(macrosEl); fMacros.serialize(macrosEl);
} }
if(fExtSettingsProvider != null){ if(fExtSettingsProvider != null){
ICStorageElement child = settings.createChild(CExternalSettingsHolder.ELEMENT_EXT_SETTINGS_CONTAINER); ICStorageElement child = settings.createChild(CExternalSettingsHolder.ELEMENT_EXT_SETTINGS_CONTAINER);
fExtSettingsProvider.serialize(child); fExtSettingsProvider.serialize(child);
} }
// if(fRefInfoMap != null && fRefInfoMap.size() != 0){ // if(fRefInfoMap != null && fRefInfoMap.size() != 0){
// ICStorageElement el = settings.createChild(ELEMENT_REFERENCES); // ICStorageElement el = settings.createChild(ELEMENT_REFERENCES);
// for(Iterator iter = fRefInfoMap.values().iterator(); iter.hasNext();){ // for(Iterator iter = fRefInfoMap.values().iterator(); iter.hasNext();){
@ -372,11 +375,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// info.serialize(child); // info.serialize(child);
// } // }
// } // }
ICStorageElement extEl = settings.createChild(PROJECT_EXTENSIONS); ICStorageElement extEl = settings.createChild(PROJECT_EXTENSIONS);
encodeProjectExtensions(extEl); encodeProjectExtensions(extEl);
} }
public boolean isReadOnly(){ public boolean isReadOnly(){
return fCfg.isReadOnly(); return fCfg.isReadOnly();
} }
@ -390,7 +393,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fMacros = new StorableCdtVariables(isReadOnly()); fMacros = new StorableCdtVariables(isReadOnly());
return fMacros; return fMacros;
} }
public StorableEnvironment getEnvironment(){ public StorableEnvironment getEnvironment(){
return fEnvironment; return fEnvironment;
} }
@ -398,7 +401,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
public void setEnvironment(StorableEnvironment environment){ public void setEnvironment(StorableEnvironment environment){
fEnvironment = environment; fEnvironment = environment;
} }
public Map<String, String> getReferenceInfo(){ public Map<String, String> getReferenceInfo(){
if(!fCfg.isReadOnly()) if(!fCfg.isReadOnly())
return CfgExportSettingContainerFactory.getReferenceMap(fCfg); return CfgExportSettingContainerFactory.getReferenceMap(fCfg);
@ -407,7 +410,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
return new LinkedHashMap<String, String>(fRefMapCache); return new LinkedHashMap<String, String>(fRefMapCache);
// if(fRefInfoMap == null || fRefInfoMap.size() == 0) // if(fRefInfoMap == null || fRefInfoMap.size() == 0)
// return new HashMap(0); // return new HashMap(0);
// //
// Map map = (HashMap)fRefInfoMap.clone(); // Map map = (HashMap)fRefInfoMap.clone();
// for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ // for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
// Map.Entry entry = (Map.Entry)iter.next(); // Map.Entry entry = (Map.Entry)iter.next();
@ -416,18 +419,18 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// } // }
// return map; // return map;
} }
// public Map getProjectRefInfoMap(){ // public Map getProjectRefInfoMap(){
// if(fRefInfoMap == null || fRefInfoMap.size() == 0) // if(fRefInfoMap == null || fRefInfoMap.size() == 0)
// return new HashMap(0); // return new HashMap(0);
// //
// return (Map)fRefInfoMap.clone(); // return (Map)fRefInfoMap.clone();
// } // }
// public void setProjectRefInfoMap(Map map){ // public void setProjectRefInfoMap(Map map){
// if(map == null && map.size() == 0) // if(map == null && map.size() == 0)
// fRefInfoMap = null; // fRefInfoMap = null;
// //
// fRefInfoMap = new HashMap(map); // fRefInfoMap = new HashMap(map);
// fIsModified = true; // fIsModified = true;
// } // }
@ -451,13 +454,13 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
// } // }
} }
/* /*
private Map getExternalSettingsProviderMap(boolean create){ private Map getExternalSettingsProviderMap(boolean create){
if(fExternalSettingsProviderMap == null && create) if(fExternalSettingsProviderMap == null && create)
fExternalSettingsProviderMap = new HashMap(); fExternalSettingsProviderMap = new HashMap();
return fExternalSettingsProviderMap; return fExternalSettingsProviderMap;
} }
public ExternalSettingInfo getExternalSettingsProviderInfo(String id){ public ExternalSettingInfo getExternalSettingsProviderInfo(String id){
Map map = getExternalSettingsProviderMap(false); Map map = getExternalSettingsProviderMap(false);
if(map != null) if(map != null)
@ -468,11 +471,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
public void setExternalSettingsProviderInfo(ExternalSettingInfo info){ public void setExternalSettingsProviderInfo(ExternalSettingInfo info){
getExternalSettingsProviderMap(true).put(info.fProvider.getId(), info.fProvider); getExternalSettingsProviderMap(true).put(info.fProvider.getId(), info.fProvider);
} }
*/ */
public ICExternalSetting[] getExternalSettings(){ public ICExternalSetting[] getExternalSettings(){
return fExtSettingsProvider.getExternalSettings(); return fExtSettingsProvider.getExternalSettings();
} }
public ICExternalSetting createExternalSetting(String[] languageIDs, public ICExternalSetting createExternalSetting(String[] languageIDs,
String[] contentTypeIDs, String[] extensions, String[] contentTypeIDs, String[] extensions,
ICSettingEntry[] entries) { ICSettingEntry[] entries) {
@ -490,13 +493,13 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
public boolean isModified(){ public boolean isModified(){
if(fIsModified) if(fIsModified)
return true; return true;
if(fMacros != null && fMacros.isDirty()) if(fMacros != null && fMacros.isDirty())
return true; return true;
if(fEnvironment != null && fEnvironment.isDirty()) if(fEnvironment != null && fEnvironment.isDirty())
return true; return true;
return fExtSettingsProvider.isModified(); return fExtSettingsProvider.isModified();
} }
@ -504,11 +507,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
if(isReadOnly()) if(isReadOnly())
throw ExceptionFactory.createIsReadOnlyException(); throw ExceptionFactory.createIsReadOnlyException();
fIsModified = modified; fIsModified = modified;
if(!modified){ if(!modified){
if(fMacros != null) if(fMacros != null)
fMacros.setDirty(false); fMacros.setDirty(false);
if(fEnvironment != null) if(fEnvironment != null)
fEnvironment.setDirty(false); fEnvironment.setDirty(false);
} }
@ -517,13 +520,13 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
void setModified(){ void setModified(){
setModified(true); setModified(true);
} }
private Map<QualifiedName, Object> getSessionPropertiesMap(boolean create){ private Map<QualifiedName, Object> getSessionPropertiesMap(boolean create){
if(fSessionPropertiesMap == null && create) if(fSessionPropertiesMap == null && create)
fSessionPropertiesMap = new HashMap<QualifiedName, Object>(); fSessionPropertiesMap = new HashMap<QualifiedName, Object>();
return fSessionPropertiesMap; return fSessionPropertiesMap;
} }
public Object getSettionProperty(QualifiedName name){ public Object getSettionProperty(QualifiedName name){
Map<QualifiedName, Object> map = getSessionPropertiesMap(false); Map<QualifiedName, Object> map = getSessionPropertiesMap(false);
return map != null ? map.get(name) : null; return map != null ? map.get(name) : null;
@ -539,7 +542,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
map.remove(name); map.remove(name);
fIsModified = true; fIsModified = true;
} }
//extension reference info //extension reference info
private HashMap<String, CConfigExtensionReference[]> getExtMap(){ private HashMap<String, CConfigExtensionReference[]> getExtMap(){
@ -547,32 +550,33 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fExtMap = new HashMap<String, CConfigExtensionReference[]>(); fExtMap = new HashMap<String, CConfigExtensionReference[]>();
return fExtMap; return fExtMap;
} }
@SuppressWarnings("unchecked")
public Map<String, CConfigExtensionReference[]> getExtensionMapCopy(){ public Map<String, CConfigExtensionReference[]> getExtensionMapCopy(){
return (HashMap<String, CConfigExtensionReference[]>)getExtMap().clone(); return (HashMap<String, CConfigExtensionReference[]>)getExtMap().clone();
} }
private ICConfigExtensionReference[] doGet(String extensionPointID){ private ICConfigExtensionReference[] doGet(String extensionPointID){
return getExtMap().get(extensionPointID); return getExtMap().get(extensionPointID);
} }
public ICConfigExtensionReference[] get(String extensionPointID) { public ICConfigExtensionReference[] get(String extensionPointID) {
checkReconsile(extensionPointID, true); checkReconsile(extensionPointID, true);
ICConfigExtensionReference refs[] = doGet(extensionPointID); ICConfigExtensionReference refs[] = doGet(extensionPointID);
if (refs == null) if (refs == null)
return new ICConfigExtensionReference[0]; return new ICConfigExtensionReference[0];
return refs.clone(); return refs.clone();
} }
private void checkReconsile(String extensionPointID, boolean toExt){ private void checkReconsile(String extensionPointID, boolean toExt){
if(toExt){ if(toExt){
Set[] delta = getReferenceDelta(extensionPointID); Set[] delta = getReferenceDelta(extensionPointID);
if(delta != null){ if(delta != null){
if(delta[0] != null){ if(delta[0] != null){
for(Iterator iter = delta[0].iterator(); iter.hasNext();){ Set<ICConfigExtensionReference> extSet = delta[0];
ICConfigExtensionReference ref = (ICConfigExtensionReference)iter.next(); for (ICConfigExtensionReference ref : extSet) {
try { try {
doRemove(ref); doRemove(ref);
} catch (CoreException e) { } catch (CoreException e) {
@ -581,8 +585,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
} }
if(delta[1] != null){ if(delta[1] != null){
for(Iterator iter = delta[1].iterator(); iter.hasNext();){ Set<String> idSet =delta[1];
String id = (String)iter.next(); for (String id : idSet) {
try { try {
doCreate(extensionPointID, id); doCreate(extensionPointID, id);
} catch (CoreException e) { } catch (CoreException e) {
@ -605,11 +609,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
} }
} }
private String[] getIds(ICConfigExtensionReference refs[]){ private String[] getIds(ICConfigExtensionReference refs[]){
if(refs == null || refs.length == 0) if(refs == null || refs.length == 0)
return new String[0]; return new String[0];
String[] ids = new String[refs.length]; String[] ids = new String[refs.length];
for(int i = 0; i < refs.length; i++){ for(int i = 0; i < refs.length; i++){
ids[i] = refs[i].getID(); ids[i] = refs[i].getID();
@ -621,7 +625,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
checkReconsile(CCorePlugin.BINARY_PARSER_UNIQ_ID, toExts); checkReconsile(CCorePlugin.BINARY_PARSER_UNIQ_ID, toExts);
checkReconsile(CCorePlugin.ERROR_PARSER_UNIQ_ID, toExts); checkReconsile(CCorePlugin.ERROR_PARSER_UNIQ_ID, toExts);
} }
// private boolean checkReconsile(String extPointId, ICConfigExtensionReference refs[], boolean get){ // private boolean checkReconsile(String extPointId, ICConfigExtensionReference refs[], boolean get){
// if(!get || !(((IInternalCCfgInfo)fCfg).getConfigurationData(false) instanceof CConfigurationDescriptionCache)){ // if(!get || !(((IInternalCCfgInfo)fCfg).getConfigurationData(false) instanceof CConfigurationDescriptionCache)){
// if(CCorePlugin.BINARY_PARSER_UNIQ_ID.equals(extPointId)) // if(CCorePlugin.BINARY_PARSER_UNIQ_ID.equals(extPointId))
@ -659,7 +663,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
extensions[extensions.length - 1] = new CConfigExtensionReference(this, extensionPoint, extension); extensions[extensions.length - 1] = new CConfigExtensionReference(this, extensionPoint, extension);
return extensions[extensions.length - 1]; return extensions[extensions.length - 1];
} }
private ICConfigExtensionReference doCreate(String extensionPoint, String extension) throws CoreException { private ICConfigExtensionReference doCreate(String extensionPoint, String extension) throws CoreException {
ICConfigExtensionReference extRef = createRef(extensionPoint, extension); ICConfigExtensionReference extRef = createRef(extensionPoint, extension);
return extRef; return extRef;
@ -668,10 +672,10 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
// boolean fireEvent = false; // boolean fireEvent = false;
checkReconsile(extensionPoint, true); checkReconsile(extensionPoint, true);
ICConfigExtensionReference[] refs = doGet(extensionPoint); ICConfigExtensionReference[] refs = doGet(extensionPoint);
ICConfigExtensionReference extRef = null; ICConfigExtensionReference extRef = null;
if (refs != null) { if (refs != null) {
for (ICConfigExtensionReference ref : refs) { for (ICConfigExtensionReference ref : refs) {
if(ref.getID().equals(extension)){ if(ref.getID().equals(extension)){
@ -680,7 +684,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
} }
} }
if(extRef == null){ if(extRef == null){
extRef = createRef(extensionPoint, extension); extRef = createRef(extensionPoint, extension);
checkReconsile(extensionPoint, false); checkReconsile(extensionPoint, false);
@ -718,7 +722,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
public void remove(ICConfigExtensionReference ext) throws CoreException { public void remove(ICConfigExtensionReference ext) throws CoreException {
doRemove(ext); doRemove(ext);
fIsModified = true; fIsModified = true;
} }
@ -742,11 +746,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
public void remove(String extensionPoint) throws CoreException { public void remove(String extensionPoint) throws CoreException {
boolean changed = doRemove(extensionPoint); boolean changed = doRemove(extensionPoint);
checkReconsile(extensionPoint, false); checkReconsile(extensionPoint, false);
if(changed) if(changed)
fIsModified = true; fIsModified = true;
} }
@ -827,14 +831,16 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
} }
public ICStorageElement importStorage(String id, ICStorageElement el) throws CoreException { public ICStorageElement importStorage(String id, ICStorageElement el) throws CoreException {
return getStorageBase().importStorage(id, el); return getStorageBase().importStorage(id, el);
} }
private void copyExtensionInfo(CConfigurationSpecSettings other){ private void copyExtensionInfo(CConfigurationSpecSettings other){
other.reconcileExtensionSettings(true); other.reconcileExtensionSettings(true);
if(other.fExtMap != null && other.fExtMap.size() != 0){ if(other.fExtMap != null && other.fExtMap.size() != 0){
fExtMap = (HashMap<String, CConfigExtensionReference[]>)other.fExtMap.clone(); @SuppressWarnings("unchecked")
HashMap<String, CConfigExtensionReference[]> clone = (HashMap<String, CConfigExtensionReference[]>)other.fExtMap.clone();
fExtMap = clone;
for (Map.Entry<String, CConfigExtensionReference[]> entry : fExtMap.entrySet()) { for (Map.Entry<String, CConfigExtensionReference[]> entry : fExtMap.entrySet()) {
CConfigExtensionReference refs[] = entry.getValue(); CConfigExtensionReference refs[] = entry.getValue();
refs = refs.clone(); refs = refs.clone();
@ -844,7 +850,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
entry.setValue(refs); entry.setValue(refs);
} }
} }
if(other.fExtInfoMap != null && other.fExtInfoMap.size() != 0){ if(other.fExtInfoMap != null && other.fExtInfoMap.size() != 0){
for (Map.Entry<CConfigExtensionReference, CExtensionInfo> entry : fExtInfoMap.entrySet()) { for (Map.Entry<CConfigExtensionReference, CExtensionInfo> entry : fExtInfoMap.entrySet()) {
CExtensionInfo info = entry.getValue(); CExtensionInfo info = entry.getValue();
@ -853,15 +859,15 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
} }
} }
public COwner getCOwner(){ public COwner getCOwner(){
return fOwner; return fOwner;
} }
public String getCOwnerId(){ public String getCOwnerId(){
return fOwnerId; return fOwnerId;
} }
private static boolean usesCache(ICConfigurationDescription cfg){ private static boolean usesCache(ICConfigurationDescription cfg){
CConfigurationData data = ((IInternalCCfgInfo)cfg).getConfigurationData(false); CConfigurationData data = ((IInternalCCfgInfo)cfg).getConfigurationData(false);
if(data instanceof CConfigurationDescriptionCache){ if(data instanceof CConfigurationDescriptionCache){
@ -889,8 +895,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
return null; return null;
} }
private Set[] getReferenceDelta(ICConfigExtensionReference refs[], String[] extIds){ private Set[] getReferenceDelta(ICConfigExtensionReference refs[], String[] extIds){
if(refs == null || refs.length == 0){ if(refs == null || refs.length == 0){
if(extIds == null || extIds.length == 0) if(extIds == null || extIds.length == 0)
@ -900,19 +906,19 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
Map<String, ICConfigExtensionReference> map = createRefMap(refs); Map<String, ICConfigExtensionReference> map = createRefMap(refs);
return new Set[]{new HashSet<ICConfigExtensionReference>(map.values()), null}; return new Set[]{new HashSet<ICConfigExtensionReference>(map.values()), null};
} }
Set<String> idSet = new HashSet<String>(Arrays.asList(extIds)); Set<String> idSet = new HashSet<String>(Arrays.asList(extIds));
Set<String> idSetCopy = new HashSet<String>(idSet); Set<String> idSetCopy = new HashSet<String>(idSet);
Map<String, ICConfigExtensionReference> refsMap = createRefMap(refs); Map<String, ICConfigExtensionReference> refsMap = createRefMap(refs);
idSet.removeAll(refsMap.keySet()); idSet.removeAll(refsMap.keySet());
refsMap.keySet().removeAll(idSetCopy); refsMap.keySet().removeAll(idSetCopy);
Set<ICConfigExtensionReference> extSet = new HashSet<ICConfigExtensionReference>(refsMap.values()); Set<ICConfigExtensionReference> extSet = new HashSet<ICConfigExtensionReference>(refsMap.values());
return new Set[]{extSet, idSet}; return new Set[]{extSet, idSet};
} }
private Map<String, ICConfigExtensionReference> createRefMap(ICConfigExtensionReference refs[]){ private Map<String, ICConfigExtensionReference> createRefMap(ICConfigExtensionReference refs[]){
Map<String, ICConfigExtensionReference> refsMap = new HashMap<String, ICConfigExtensionReference>(refs.length); Map<String, ICConfigExtensionReference> refsMap = new HashMap<String, ICConfigExtensionReference>(refs.length);
for (ICConfigExtensionReference ref : refs) { for (ICConfigExtensionReference ref : refs) {
@ -920,16 +926,16 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
} }
return refsMap; return refsMap;
} }
boolean extRefSettingsEqual(CConfigurationSpecSettings other){ boolean extRefSettingsEqual(CConfigurationSpecSettings other){
if(fExtMap == null || fExtMap.size() == 0) if(fExtMap == null || fExtMap.size() == 0)
return other.fExtMap == null || other.fExtMap.size() == 0; return other.fExtMap == null || other.fExtMap.size() == 0;
if(other.fExtMap == null || other.fExtMap.size() == 0) if(other.fExtMap == null || other.fExtMap.size() == 0)
return false; return false;
if(fExtMap.size() != other.fExtMap.size()) if(fExtMap.size() != other.fExtMap.size())
return false; return false;
for (Entry<String, CConfigExtensionReference[]> entry : fExtMap.entrySet()) { for (Entry<String, CConfigExtensionReference[]> entry : fExtMap.entrySet()) {
ICConfigExtensionReference[] thisRefs = entry.getValue(); ICConfigExtensionReference[] thisRefs = entry.getValue();
ICConfigExtensionReference[] otherRefs = other.fExtMap.get(entry.getKey()); ICConfigExtensionReference[] otherRefs = other.fExtMap.get(entry.getKey());
@ -937,24 +943,24 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
return thisRefs.length == 0; return thisRefs.length == 0;
if(thisRefs.length != otherRefs.length) if(thisRefs.length != otherRefs.length)
return false; return false;
Map<String, ICConfigExtensionReference> map = createRefMap(thisRefs); Map<String, ICConfigExtensionReference> map = createRefMap(thisRefs);
map.entrySet().removeAll(createRefMap(otherRefs).entrySet()); map.entrySet().removeAll(createRefMap(otherRefs).entrySet());
if(map.size() != 0) if(map.size() != 0)
return false; return false;
} }
return true; return true;
} }
public String[] getExternalSettingsProviderIds(){ public String[] getExternalSettingsProviderIds(){
return ExtensionContainerFactory.getReferencedProviderIds(fCfg); return ExtensionContainerFactory.getReferencedProviderIds(fCfg);
} }
public void setExternalSettingsProviderIds(String ids[]){ public void setExternalSettingsProviderIds(String ids[]){
ExtensionContainerFactory.setReferencedProviderIds(fCfg, ids); ExtensionContainerFactory.setReferencedProviderIds(fCfg, ids);
} }
public void updateExternalSettingsProviders(String[] ids){ public void updateExternalSettingsProviders(String[] ids){
ExtensionContainerFactory.updateReferencedProviderIds(fCfg, ids); ExtensionContainerFactory.updateReferencedProviderIds(fCfg, ids);
} }