diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java index fb5909ff556..0da93430cc1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java @@ -16,9 +16,10 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.IPath; public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICExclusionPatternPathEntry { - private IPath[] exclusionPatterns; + private final IPath[] exclusionPatterns; private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ - char[][]fullCharExclusionPatterns = UNINIT_PATTERNS; + /** calculated value, does not have to be final */ + char[][] fullCharExclusionPatterns = UNINIT_PATTERNS; ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) { @@ -74,17 +75,25 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx } @Override - public boolean equals(Object other) { - if(!super.equals(other)) + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) return false; - - ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other; - return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); + if (getClass() != obj.getClass()) + return false; + ACExclusionFilterEntry other = (ACExclusionFilterEntry) obj; + if (!Arrays.equals(exclusionPatterns, other.exclusionPatterns)) + return false; + return true; } @Override public int hashCode() { - return super.hashCode() + exclusionPatterns.hashCode(); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Arrays.hashCode(exclusionPatterns); + return result; } @Override diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java index 39657fbf3d6..0fde81780b2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java @@ -114,6 +114,6 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry @Override protected String contentsToString() { - return fName; + return getName(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java index 0c2dc98335d..fd79a81211d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Intel Corporation and others. + * Copyright (c) 2007, 2012 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 @@ -13,11 +13,9 @@ package org.eclipse.cdt.core.settings.model; import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer; import org.eclipse.cdt.internal.core.SafeStringInterner; - - public abstract class ACSettingEntry implements ICSettingEntry { - int fFlags; - String fName; + private final int fFlags; + private final String fName; ACSettingEntry(String name, int flags){ fName = SafeStringInterner.safeIntern(name); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java index 42b787de15c..9882080474f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java @@ -20,9 +20,9 @@ import org.eclipse.core.runtime.Path; * As an example, those are supplied by a gcc compiler with option "-l". */ public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFileEntry { - private IPath fSourceAttachmentPath; - private IPath fSourceAttachmentRootPath; - private IPath fSourceAttachmentPrefixMapping; + private final IPath fSourceAttachmentPath; + private final IPath fSourceAttachmentRootPath; + private final IPath fSourceAttachmentPrefixMapping; /** * This constructor is discouraged to be referenced by clients. @@ -64,38 +64,33 @@ public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFil this(rc, flags, null, null, null); } - public CLibraryFileEntry(String value, - int flags, + public CLibraryFileEntry(String name, int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { - super(value, flags); - setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); + super(name, flags); + + fSourceAttachmentPath = sourceAttachmentPath; + fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; + fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY; } - public CLibraryFileEntry(IPath location, - int flags, + public CLibraryFileEntry(IPath location, int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { super(location, flags); - setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); + + fSourceAttachmentPath = sourceAttachmentPath; + fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; + fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY; } - public CLibraryFileEntry(IFile rc, - int flags, + public CLibraryFileEntry(IFile rc, int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { super(rc, flags); - setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); - } - - private void setSourceAttachmentSettings(IPath sourceAttachmentPath, - IPath sourceAttachmentRootPath, - IPath sourceAttachmentPrefixMapping){ - if(sourceAttachmentPath == null) - return; fSourceAttachmentPath = sourceAttachmentPath; fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; @@ -132,10 +127,8 @@ public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFil final int prime = 31; int result = super.hashCode(); result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode()); - result = prime * result - + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode()); - result = prime * result - + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode()); + result = prime * result + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode()); + result = prime * result + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode()); return result; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java index d0b940a6dee..b17469edda3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.internal.core.SafeStringInterner; * As an example, those are supplied by a gcc compiler with option "-D". */ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry { - private String fValue; + private final String fValue; /** * This constructor is discouraged to be referenced by clients. @@ -30,9 +30,8 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry { */ public CMacroEntry(String name, String value, int flags) { super(name, flags); - fValue = SafeStringInterner.safeIntern(value); - if(fValue == null) - fValue = ""; //$NON-NLS-1$ + String val = SafeStringInterner.safeIntern(value); + fValue = val != null ? val : ""; //$NON-NLS-1$ } @Override @@ -80,7 +79,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry { @Override protected String contentsToString() { - return new StringBuffer().append(fName).append('=').append(fValue).toString(); + return new StringBuffer().append(getName()).append('=').append(fValue).toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java index af776d96bc0..759e0e18b42 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java @@ -11,10 +11,16 @@ package org.eclipse.cdt.core.settings.model; import org.eclipse.cdt.core.model.IIncludeEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; /** + * An interface representing setting entries. + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. + * + * Any class implementing this interface should be immutable so the setting + * entries could be safely pooled by {@link CDataUtil#getPooledEntry(ICSettingEntry)}. */ public interface ICSettingEntry { /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java index e025c031dd8..ea4181095de 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Intel Corporation and others. + * Copyright (c) 2007, 2012 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Intel Corporation - Initial API and implementation + * Intel Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.settings.model.extension.impl; @@ -17,11 +17,14 @@ import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.EntryStore; import org.eclipse.cdt.core.settings.model.util.KindBasedStore; +import org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache; public class CDefaultLanguageData extends CLanguageData { + @Deprecated /** not used anymore */ protected final static int OP_COPY = 1; + @Deprecated /** not used anymore */ protected final static int OP_SET = 2; - + protected String fName; protected String fId; protected String fLanguageId; @@ -45,32 +48,32 @@ public class CDefaultLanguageData extends CLanguageData { // factory = new CDataFacroty(); // fFactory = factory; // } - + protected CDefaultLanguageData(){ fStore = createStore(); } - + public CDefaultLanguageData(String id, - String languageId, - String ids[], + String languageId, + String ids[], boolean isContentTypes) { fId = id; fLanguageId = languageId; - + if(isContentTypes) fSourceContentTypeIds = ids.clone(); else fSourceExts = ids.clone(); - + fStore = createStore(); } - + public CDefaultLanguageData(String id, CLanguageData base) { fId = id; copySettingsFrom(base); } - + protected void copySettingsFrom(CLanguageData data){ fName = data.getName(); fLanguageId = data.getLanguageId(); @@ -81,27 +84,30 @@ public class CDefaultLanguageData extends CLanguageData { // fHeaderExts = data.getHeaderExtensions(); fStore = createStore(data); } - + protected EntryStore createStore(CLanguageData data){ - EntryStore store = createStore(); + EntryStore store = createStore(); int kinds[] = KindBasedStore.getLanguageEntryKinds(); for (int kind : kinds) { ICLanguageSettingEntry entries[] = getEntriesToCopy(kind, data); entries = processStoredEntries(entries, OP_COPY); store.storeEntries(kind, entries); - + } return store; } - + protected ICLanguageSettingEntry[] getEntriesToCopy(int kind, CLanguageData lData){ return lData.getEntries(kind); } - + + /** + * This method is overridden in {@link CLanguageSettingCache} to ensure the entries are cached with {@link CDataUtil} pool. + */ protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){ return entries; } - + protected EntryStore createStore(){ return new EntryStore(true); } @@ -130,9 +136,9 @@ public class CDefaultLanguageData extends CLanguageData { public void setLanguageId(String id) { if(CDataUtil.objectsEqual(id, fLanguageId)) return; - + fLanguageId = id; - + setModified(true); } @@ -147,7 +153,7 @@ public class CDefaultLanguageData extends CLanguageData { public ICLanguageSettingEntry[] getSettingEntries(int kind) { return fStore.getEntries(kind); List list = new ArrayList(); - + if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) { addLanguageEntries(ICLanguageSettingEntry.INCLUDE_PATH, list); } else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) { @@ -165,7 +171,7 @@ public class CDefaultLanguageData extends CLanguageData { return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]); } - + private List addLanguageEntries(int kind, List list){ ICLanguageSettingEntry entries[] = fStore.getEntries(kind); for(int i = 0; i < entries.length; i++){ @@ -198,7 +204,7 @@ public class CDefaultLanguageData extends CLanguageData { public void setEntries(int kind, ICLanguageSettingEntry entries[]) { entries = processStoredEntries(entries, OP_SET); fStore.storeEntries(kind, entries); - + setModified(true); } @@ -211,10 +217,10 @@ public class CDefaultLanguageData extends CLanguageData { public void setSourceContentTypeIds(String[] ids) { if(Arrays.equals(ids, fSourceContentTypeIds)) return; - + fSourceContentTypeIds = ids != null ? (String[])ids.clone() : null; - + setModified(true); } @@ -222,17 +228,17 @@ public class CDefaultLanguageData extends CLanguageData { public void setSourceExtensions(String[] exts) { if(Arrays.equals(exts, fSourceExts)) return; - + fSourceExts = exts != null ? (String[])exts.clone() : null; - + setModified(true); } - + public boolean isModified(){ return fIsModified; } - + public void setModified(boolean modified){ fIsModified = modified; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java index eda51685d14..ab217399b42 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java @@ -277,8 +277,9 @@ public class CDataUtil { * * @since 5.4 */ - public static ICSettingEntry getPooledEntry(ICSettingEntry entry) { - return settingEntriesPool.add(entry); + @SuppressWarnings("unchecked") + public static T getPooledEntry(T entry) { + return (T) settingEntriesPool.add(entry); } /** @@ -329,7 +330,7 @@ public class CDataUtil { ); break; } - return (ICLanguageSettingEntry) getPooledEntry(entry); + return getPooledEntry(entry); } /** @@ -386,7 +387,7 @@ public class CDataUtil { * @since 5.4 */ public static CIncludePathEntry createCIncludePathEntry(String name, int flags) { - return (CIncludePathEntry) getPooledEntry(new CIncludePathEntry(name, flags)); + return getPooledEntry(new CIncludePathEntry(name, flags)); } /** @@ -396,7 +397,7 @@ public class CDataUtil { * @since 5.4 */ public static CIncludeFileEntry createCIncludeFileEntry(String name, int flags) { - return (CIncludeFileEntry) getPooledEntry(new CIncludeFileEntry(name, flags)); + return getPooledEntry(new CIncludeFileEntry(name, flags)); } /** @@ -406,7 +407,7 @@ public class CDataUtil { * @since 5.4 */ public static CMacroEntry createCMacroEntry(String name, String value, int flags) { - return (CMacroEntry) getPooledEntry(new CMacroEntry(name, value, flags)); + return getPooledEntry(new CMacroEntry(name, value, flags)); } /** @@ -416,7 +417,7 @@ public class CDataUtil { * @since 5.4 */ public static CMacroFileEntry createCMacroFileEntry(String name, int flags) { - return (CMacroFileEntry) getPooledEntry(new CMacroFileEntry(name, flags)); + return getPooledEntry(new CMacroFileEntry(name, flags)); } /** @@ -426,7 +427,7 @@ public class CDataUtil { * @since 5.4 */ public static CLibraryPathEntry createCLibraryPathEntry(String name, int flags) { - return (CLibraryPathEntry) getPooledEntry(new CLibraryPathEntry(name, flags)); + return getPooledEntry(new CLibraryPathEntry(name, flags)); } /** @@ -436,7 +437,7 @@ public class CDataUtil { * @since 5.4 */ public static CLibraryFileEntry createCLibraryFileEntry(String name, int flags) { - return (CLibraryFileEntry) getPooledEntry(new CLibraryFileEntry(name, flags)); + return getPooledEntry(new CLibraryFileEntry(name, flags)); } public static String[] getSourceExtensions(IProject project, CLanguageData data) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java index c611974c6e2..bd0d90b5e48 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java @@ -12,117 +12,27 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model.util; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; - -import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.core.runtime.IPath; /** - * Cache of setting entries stored with multidimentional maps. - * See bug 284699 comment 7 for a possible insight into it. + * Used to be factory/cache of setting entries. Superseded by {@link CDataUtil} pool of entries. + * Not used in CDT anymore. + * + * @deprecated Since CDT 9.0. Use corresponding {@link CDataUtil} methods instead. */ +@Deprecated public class CSettingEntryFactory { - private static final HashSet EMPTY_SET = new HashSet(0); - - private KindBasedStore> fStore = new KindBasedStore>(false); - - private HashMap> getNameMap(int kind, boolean create){ - @SuppressWarnings("unchecked") - HashMap> map = (HashMap>) fStore.get(kind); - if(map == null && create){ - map = new HashMap>(); - fStore.put(kind, map); - } - return map; + public ICSettingEntry getEntry(ICSettingEntry entry) { + return CDataUtil.getPooledEntry(entry); } - - private HashMap> getValueMap(String name, boolean create){ - HashMap>> nameMap = getNameMap(ICSettingEntry.MACRO, create); - if(nameMap != null){ - return getMap(nameMap, name, create); - } - return null; + public ICLanguageSettingEntry getLanguageSettingEntry(ICLanguageSettingEntry entry) { + return CDataUtil.getPooledEntry(entry); } - - private HashMap getFlagMap(int kind, String name, String value, IPath[] exclusionPatterns, boolean create){ - switch(kind){ - case ICSettingEntry.MACRO: - HashMap> valueMap = getValueMap(name, create); - if(valueMap != null){ - return getMap(valueMap, value, create); - } - return null; - case ICSettingEntry.SOURCE_PATH: - case ICSettingEntry.OUTPUT_PATH: - HashMap, HashMap> excPatternMap = getExclusionPatternsMap(kind, name, create); - if(excPatternMap != null){ - HashSet setKey = exclusionPatterns == null || exclusionPatterns.length == 0 ? EMPTY_SET : new HashSet(Arrays.asList(exclusionPatterns)); - return getMap(excPatternMap, setKey, create); - } - return null; - default: - HashMap> nameMap = getNameMap(kind, create); - if(nameMap != null){ - return getMap(nameMap, name, create); - } - return null; - } + public ICSettingEntry getEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, boolean create) { + return CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags); } - - private HashMap, HashMap> getExclusionPatternsMap(int kind, String name, boolean create){ - HashMap/*exclusionPatterns*/, HashMap>> nameMap = getNameMap(kind, create); - if(nameMap != null){ - return getMap(nameMap, name, create); - } - return null; - } - - private static HashMap getMap(HashMap> container, Key key, boolean create){ - HashMap map = container.get(key); - if(map == null && create){ - map = new HashMap(); - container.put(key, map); - } - return map; - } - - public ICSettingEntry getEntry(ICSettingEntry entry){ - switch(entry.getKind()){ - case ICSettingEntry.OUTPUT_PATH: - case ICSettingEntry.SOURCE_PATH: - return getEntry(entry.getKind(), entry.getName(), null, ((ICExclusionPatternPathEntry)entry).getExclusionPatterns(), entry.getFlags(), entry, true); - default: - return getLanguageSettingEntry((ICLanguageSettingEntry)entry); - } - } - - public ICLanguageSettingEntry getLanguageSettingEntry(ICLanguageSettingEntry lEntry){ - return (ICLanguageSettingEntry)getEntry(lEntry.getKind(), lEntry.getName(), lEntry.getValue(), null, lEntry.getFlags(), lEntry, true); - } - - public ICSettingEntry getEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, boolean create){ - return getEntry(kind, name, value, exclusionPatterns, flags, null, create); - } - - private ICSettingEntry getEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, ICSettingEntry baseEntry, boolean create){ - HashMap flagMap = getFlagMap(kind, name, value, exclusionPatterns, create); - if(flagMap != null){ - Integer iFlags = new Integer(flags); - ICSettingEntry entry = flagMap.get(iFlags); - if(entry == null && create){ - entry = baseEntry != null ? baseEntry : CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags); - flagMap.put(iFlags, entry); - } - return entry; - } - return null; - } - - public void clear(){ - fStore.clear(); + public void clear() { } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index 0f537ed8b63..8a50d8369ed 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -44,7 +44,6 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData; import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData; import org.eclipse.cdt.core.settings.model.util.CDataUtil; -import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager; import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables; @@ -67,7 +66,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData private boolean fDataLoadded; private boolean fInitializing; private ICConfigurationDescription fBaseDescription; - private CSettingEntryFactory fSettingsFactory; private ICSourceEntry[] fResolvedSourceEntries; CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{ @@ -86,7 +84,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fInitializing; } - void loadData(CSettingEntryFactory factory) throws CoreException{ + void loadData() throws CoreException{ if(fDataLoadded) return; @@ -94,12 +92,8 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fData = CProjectDescriptionManager.getInstance().loadData(this, null); - fSettingsFactory = factory; - copySettingsFrom(fData, true); - fSettingsFactory = null; - fSpecSettings.reconcileExtensionSettings(true); ((CBuildSettingCache)fBuildData).initEnvironmentCache(); ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); @@ -130,7 +124,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fBaseCache; } - boolean applyData(CSettingEntryFactory factory, SettingsContext context) throws CoreException{ + boolean applyData(SettingsContext context) throws CoreException{ boolean modified = true; if(fBaseDescription != null){ @@ -138,7 +132,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fDataLoadded = true; fName = fData.getName(); fId = fData.getId(); - fSettingsFactory = factory; if((context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_SETTINGS_UNMODIFIED) == 0 || fBaseCache == null){ copySettingsFrom(fData, true); @@ -149,8 +142,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData modified = (context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_STORAGE_UNMODIFIED) == 0; } - fSettingsFactory = null; - ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); fMacros = new StorableCdtVariables(vars, true); fSpecSettings.serialize(); @@ -164,10 +155,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return modified; } - CSettingEntryFactory getSettingsFactory(){ - return fSettingsFactory; - } - public StorableCdtVariables getCachedVariables(){ return fMacros; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java index abddfa77cae..8f03fde8f1f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.settings.model.ICSettingContainer; import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData; import org.eclipse.cdt.core.settings.model.util.CDataUtil; -import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.cdt.core.settings.model.util.EntryStore; import org.eclipse.core.resources.IProject; @@ -177,16 +176,9 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements } @Override - protected ICLanguageSettingEntry[] processStoredEntries( - ICLanguageSettingEntry[] entries, int op) { - if(entries.length != 0){ - CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)getConfiguration(); - CSettingEntryFactory factory = cfgCache.getSettingsFactory(); - if(factory != null){ - for(int i = 0; i < entries.length; i++){ - entries[i] = factory.getLanguageSettingEntry(entries[i]); - } - } + protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op) { + for(int i = 0; i < entries.length; i++) { + entries[i] = CDataUtil.getPooledEntry(entries[i]); } return entries; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index fdc44e08985..f4a39275739 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.settings.model.ICSettingsStorage; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; -import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.QualifiedName; @@ -189,12 +188,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if(!fIsReadOnly || !fIsLoading) return; - CSettingEntryFactory factory = new CSettingEntryFactory(); for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); try { - cache.loadData(factory); - factory.clear(); + cache.loadData(); } catch (CoreException e) { CCorePlugin.log(e); iter.remove(); @@ -210,14 +207,12 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if(!fIsReadOnly || !fIsApplying) return false; - CSettingEntryFactory factory = new CSettingEntryFactory(); boolean modified = false; for (Iterator iter = fCfgMap.values().iterator(); iter.hasNext();) { CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); try { - if(cache.applyData(factory, context)) + if(cache.applyData(context)) modified = true; - factory.clear(); } catch (CoreException e) { CCorePlugin.log(e); e.printStackTrace(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 25bf638b9c1..7c2fe64806e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -84,7 +84,6 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData; import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter; import org.eclipse.cdt.core.settings.model.extension.impl.CDataFactory; import org.eclipse.cdt.core.settings.model.util.CDataUtil; -import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.cdt.core.settings.model.util.KindBasedStore; import org.eclipse.cdt.core.settings.model.util.ListComparator; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; @@ -2315,11 +2314,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ICStorageElement baseRootEl = settings.getRootStorageElement(); rootEl = rootParent.importChild(baseRootEl); CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, baseCache, cfgDes.getSpecSettings(), null, rootEl); - CSettingEntryFactory factory = new CSettingEntryFactory(); SettingsContext context = new SettingsContext(null); - cache.applyData(factory, context); + cache.applyData(context); cache.doneInitialization(); - factory.clear(); runContextOperations(context, null); return cache; } @@ -2394,10 +2391,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null); - CSettingEntryFactory factory = new CSettingEntryFactory(); - cache.loadData(factory); + cache.loadData(); cache.doneInitialization(); - factory.clear(); return cache; }