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

bug 370063: CSettingEntryFactory is not needed anymore

This commit is contained in:
Andrew Gvozdev 2012-01-29 08:38:39 -05:00
parent 6680b5a020
commit d20555df6c
13 changed files with 113 additions and 222 deletions

View file

@ -16,9 +16,10 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICExclusionPatternPathEntry { 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$ 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) { ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) {
@ -74,17 +75,25 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object obj) {
if(!super.equals(other)) if (this == obj)
return true;
if (!super.equals(obj))
return false; return false;
if (getClass() != obj.getClass())
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other; return false;
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); ACExclusionFilterEntry other = (ACExclusionFilterEntry) obj;
if (!Arrays.equals(exclusionPatterns, other.exclusionPatterns))
return false;
return true;
} }
@Override @Override
public int hashCode() { 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 @Override

View file

@ -114,6 +114,6 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry
@Override @Override
protected String contentsToString() { protected String contentsToString() {
return fName; return getName();
} }
} }

View file

@ -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 * 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
@ -13,11 +13,9 @@ package org.eclipse.cdt.core.settings.model;
import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer; import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
import org.eclipse.cdt.internal.core.SafeStringInterner; import org.eclipse.cdt.internal.core.SafeStringInterner;
public abstract class ACSettingEntry implements ICSettingEntry { public abstract class ACSettingEntry implements ICSettingEntry {
int fFlags; private final int fFlags;
String fName; private final String fName;
ACSettingEntry(String name, int flags){ ACSettingEntry(String name, int flags){
fName = SafeStringInterner.safeIntern(name); fName = SafeStringInterner.safeIntern(name);

View file

@ -20,9 +20,9 @@ import org.eclipse.core.runtime.Path;
* As an example, those are supplied by a gcc compiler with option "-l". * As an example, those are supplied by a gcc compiler with option "-l".
*/ */
public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFileEntry { public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFileEntry {
private IPath fSourceAttachmentPath; private final IPath fSourceAttachmentPath;
private IPath fSourceAttachmentRootPath; private final IPath fSourceAttachmentRootPath;
private IPath fSourceAttachmentPrefixMapping; private final IPath fSourceAttachmentPrefixMapping;
/** /**
* This constructor is discouraged to be referenced by clients. * 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); this(rc, flags, null, null, null);
} }
public CLibraryFileEntry(String value, public CLibraryFileEntry(String name, int flags,
int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
super(value, flags); super(name, flags);
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
fSourceAttachmentPath = sourceAttachmentPath;
fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY;
fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY;
} }
public CLibraryFileEntry(IPath location, public CLibraryFileEntry(IPath location, int flags,
int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
super(location, flags); 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, public CLibraryFileEntry(IFile rc, int flags,
int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
super(rc, flags); super(rc, flags);
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
}
private void setSourceAttachmentSettings(IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping){
if(sourceAttachmentPath == null)
return;
fSourceAttachmentPath = sourceAttachmentPath; fSourceAttachmentPath = sourceAttachmentPath;
fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY;
@ -132,10 +127,8 @@ public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFil
final int prime = 31; final int prime = 31;
int result = super.hashCode(); int result = super.hashCode();
result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode()); result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode());
result = prime * result result = prime * result + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode());
+ ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode()); result = prime * result + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode());
result = prime * result
+ ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode());
return result; return result;
} }

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.internal.core.SafeStringInterner;
* As an example, those are supplied by a gcc compiler with option "-D". * As an example, those are supplied by a gcc compiler with option "-D".
*/ */
public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry { public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry {
private String fValue; private final String fValue;
/** /**
* This constructor is discouraged to be referenced by clients. * 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) { public CMacroEntry(String name, String value, int flags) {
super(name, flags); super(name, flags);
fValue = SafeStringInterner.safeIntern(value); String val = SafeStringInterner.safeIntern(value);
if(fValue == null) fValue = val != null ? val : ""; //$NON-NLS-1$
fValue = ""; //$NON-NLS-1$
} }
@Override @Override
@ -80,7 +79,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry {
@Override @Override
protected String contentsToString() { protected String contentsToString() {
return new StringBuffer().append(fName).append('=').append(fValue).toString(); return new StringBuffer().append(getName()).append('=').append(fValue).toString();
} }
} }

View file

@ -11,10 +11,16 @@
package org.eclipse.cdt.core.settings.model; package org.eclipse.cdt.core.settings.model;
import org.eclipse.cdt.core.model.IIncludeEntry; 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. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented 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 { public interface ICSettingEntry {
/** /**

View file

@ -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 * 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
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.settings.model.extension.impl; 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.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.EntryStore; import org.eclipse.cdt.core.settings.model.util.EntryStore;
import org.eclipse.cdt.core.settings.model.util.KindBasedStore; import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
import org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache;
public class CDefaultLanguageData extends CLanguageData { public class CDefaultLanguageData extends CLanguageData {
@Deprecated /** not used anymore */
protected final static int OP_COPY = 1; protected final static int OP_COPY = 1;
@Deprecated /** not used anymore */
protected final static int OP_SET = 2; protected final static int OP_SET = 2;
protected String fName; protected String fName;
protected String fId; protected String fId;
protected String fLanguageId; protected String fLanguageId;
@ -45,32 +48,32 @@ public class CDefaultLanguageData extends CLanguageData {
// factory = new CDataFacroty(); // factory = new CDataFacroty();
// fFactory = factory; // fFactory = factory;
// } // }
protected CDefaultLanguageData(){ protected CDefaultLanguageData(){
fStore = createStore(); fStore = createStore();
} }
public CDefaultLanguageData(String id, public CDefaultLanguageData(String id,
String languageId, String languageId,
String ids[], String ids[],
boolean isContentTypes) { boolean isContentTypes) {
fId = id; fId = id;
fLanguageId = languageId; fLanguageId = languageId;
if(isContentTypes) if(isContentTypes)
fSourceContentTypeIds = ids.clone(); fSourceContentTypeIds = ids.clone();
else else
fSourceExts = ids.clone(); fSourceExts = ids.clone();
fStore = createStore(); fStore = createStore();
} }
public CDefaultLanguageData(String id, CLanguageData base) { public CDefaultLanguageData(String id, CLanguageData base) {
fId = id; fId = id;
copySettingsFrom(base); copySettingsFrom(base);
} }
protected void copySettingsFrom(CLanguageData data){ protected void copySettingsFrom(CLanguageData data){
fName = data.getName(); fName = data.getName();
fLanguageId = data.getLanguageId(); fLanguageId = data.getLanguageId();
@ -81,27 +84,30 @@ public class CDefaultLanguageData extends CLanguageData {
// fHeaderExts = data.getHeaderExtensions(); // fHeaderExts = data.getHeaderExtensions();
fStore = createStore(data); fStore = createStore(data);
} }
protected EntryStore createStore(CLanguageData data){ protected EntryStore createStore(CLanguageData data){
EntryStore store = createStore(); EntryStore store = createStore();
int kinds[] = KindBasedStore.getLanguageEntryKinds(); int kinds[] = KindBasedStore.getLanguageEntryKinds();
for (int kind : kinds) { for (int kind : kinds) {
ICLanguageSettingEntry entries[] = getEntriesToCopy(kind, data); ICLanguageSettingEntry entries[] = getEntriesToCopy(kind, data);
entries = processStoredEntries(entries, OP_COPY); entries = processStoredEntries(entries, OP_COPY);
store.storeEntries(kind, entries); store.storeEntries(kind, entries);
} }
return store; return store;
} }
protected ICLanguageSettingEntry[] getEntriesToCopy(int kind, CLanguageData lData){ protected ICLanguageSettingEntry[] getEntriesToCopy(int kind, CLanguageData lData){
return lData.getEntries(kind); 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){ protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){
return entries; return entries;
} }
protected EntryStore createStore(){ protected EntryStore createStore(){
return new EntryStore(true); return new EntryStore(true);
} }
@ -130,9 +136,9 @@ public class CDefaultLanguageData extends CLanguageData {
public void setLanguageId(String id) { public void setLanguageId(String id) {
if(CDataUtil.objectsEqual(id, fLanguageId)) if(CDataUtil.objectsEqual(id, fLanguageId))
return; return;
fLanguageId = id; fLanguageId = id;
setModified(true); setModified(true);
} }
@ -147,7 +153,7 @@ public class CDefaultLanguageData extends CLanguageData {
public ICLanguageSettingEntry[] getSettingEntries(int kind) { public ICLanguageSettingEntry[] getSettingEntries(int kind) {
return fStore.getEntries(kind); return fStore.getEntries(kind);
List list = new ArrayList(); List list = new ArrayList();
if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) { if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) {
addLanguageEntries(ICLanguageSettingEntry.INCLUDE_PATH, list); addLanguageEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
} else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) { } else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) {
@ -165,7 +171,7 @@ public class CDefaultLanguageData extends CLanguageData {
return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]); return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
} }
private List addLanguageEntries(int kind, List list){ private List addLanguageEntries(int kind, List list){
ICLanguageSettingEntry entries[] = fStore.getEntries(kind); ICLanguageSettingEntry entries[] = fStore.getEntries(kind);
for(int i = 0; i < entries.length; i++){ for(int i = 0; i < entries.length; i++){
@ -198,7 +204,7 @@ public class CDefaultLanguageData extends CLanguageData {
public void setEntries(int kind, ICLanguageSettingEntry entries[]) { public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
entries = processStoredEntries(entries, OP_SET); entries = processStoredEntries(entries, OP_SET);
fStore.storeEntries(kind, entries); fStore.storeEntries(kind, entries);
setModified(true); setModified(true);
} }
@ -211,10 +217,10 @@ public class CDefaultLanguageData extends CLanguageData {
public void setSourceContentTypeIds(String[] ids) { public void setSourceContentTypeIds(String[] ids) {
if(Arrays.equals(ids, fSourceContentTypeIds)) if(Arrays.equals(ids, fSourceContentTypeIds))
return; return;
fSourceContentTypeIds = ids != null ? fSourceContentTypeIds = ids != null ?
(String[])ids.clone() : null; (String[])ids.clone() : null;
setModified(true); setModified(true);
} }
@ -222,17 +228,17 @@ public class CDefaultLanguageData extends CLanguageData {
public void setSourceExtensions(String[] exts) { public void setSourceExtensions(String[] exts) {
if(Arrays.equals(exts, fSourceExts)) if(Arrays.equals(exts, fSourceExts))
return; return;
fSourceExts = exts != null ? fSourceExts = exts != null ?
(String[])exts.clone() : null; (String[])exts.clone() : null;
setModified(true); setModified(true);
} }
public boolean isModified(){ public boolean isModified(){
return fIsModified; return fIsModified;
} }
public void setModified(boolean modified){ public void setModified(boolean modified){
fIsModified = modified; fIsModified = modified;
} }

View file

@ -277,8 +277,9 @@ public class CDataUtil {
* *
* @since 5.4 * @since 5.4
*/ */
public static ICSettingEntry getPooledEntry(ICSettingEntry entry) { @SuppressWarnings("unchecked")
return settingEntriesPool.add(entry); public static <T extends ICSettingEntry> T getPooledEntry(T entry) {
return (T) settingEntriesPool.add(entry);
} }
/** /**
@ -329,7 +330,7 @@ public class CDataUtil {
); );
break; break;
} }
return (ICLanguageSettingEntry) getPooledEntry(entry); return getPooledEntry(entry);
} }
/** /**
@ -386,7 +387,7 @@ public class CDataUtil {
* @since 5.4 * @since 5.4
*/ */
public static CIncludePathEntry createCIncludePathEntry(String name, int flags) { 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 * @since 5.4
*/ */
public static CIncludeFileEntry createCIncludeFileEntry(String name, int flags) { 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 * @since 5.4
*/ */
public static CMacroEntry createCMacroEntry(String name, String value, int flags) { 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 * @since 5.4
*/ */
public static CMacroFileEntry createCMacroFileEntry(String name, int flags) { 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 * @since 5.4
*/ */
public static CLibraryPathEntry createCLibraryPathEntry(String name, int flags) { 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 * @since 5.4
*/ */
public static CLibraryFileEntry createCLibraryFileEntry(String name, int flags) { 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) { public static String[] getSourceExtensions(IProject project, CLanguageData data) {

View file

@ -12,117 +12,27 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.settings.model.util; 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.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* Cache of setting entries stored with multidimentional maps. * Used to be factory/cache of setting entries. Superseded by {@link CDataUtil} pool of entries.
* See bug 284699 comment 7 for a possible insight into it. * Not used in CDT anymore.
*
* @deprecated Since CDT 9.0. Use corresponding {@link CDataUtil} methods instead.
*/ */
@Deprecated
public class CSettingEntryFactory { public class CSettingEntryFactory {
private static final HashSet<IPath> EMPTY_SET = new HashSet<IPath>(0); public ICSettingEntry getEntry(ICSettingEntry entry) {
return CDataUtil.getPooledEntry(entry);
private KindBasedStore<HashMap<String, ?>> fStore = new KindBasedStore<HashMap<String, ?>>(false);
private <K, V> HashMap<String, HashMap<K, V>> getNameMap(int kind, boolean create){
@SuppressWarnings("unchecked")
HashMap<String/*name*/, HashMap<K, V>> map = (HashMap<String, HashMap<K, V>>) fStore.get(kind);
if(map == null && create){
map = new HashMap<String, HashMap<K, V>>();
fStore.put(kind, map);
}
return map;
} }
public ICLanguageSettingEntry getLanguageSettingEntry(ICLanguageSettingEntry entry) {
private HashMap<String, HashMap<Integer, ICSettingEntry>> getValueMap(String name, boolean create){ return CDataUtil.getPooledEntry(entry);
HashMap<String/*name*/, HashMap<String/*value*/, HashMap<Integer/*flags*/, ICSettingEntry>>> nameMap = getNameMap(ICSettingEntry.MACRO, 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) {
private HashMap<Integer, ICSettingEntry> getFlagMap(int kind, String name, String value, IPath[] exclusionPatterns, boolean create){ return CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags);
switch(kind){
case ICSettingEntry.MACRO:
HashMap<String, HashMap<Integer, ICSettingEntry>> valueMap = getValueMap(name, create);
if(valueMap != null){
return getMap(valueMap, value, create);
}
return null;
case ICSettingEntry.SOURCE_PATH:
case ICSettingEntry.OUTPUT_PATH:
HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>> excPatternMap = getExclusionPatternsMap(kind, name, create);
if(excPatternMap != null){
HashSet<IPath> setKey = exclusionPatterns == null || exclusionPatterns.length == 0 ? EMPTY_SET : new HashSet<IPath>(Arrays.asList(exclusionPatterns));
return getMap(excPatternMap, setKey, create);
}
return null;
default:
HashMap<String, HashMap<Integer, ICSettingEntry>> nameMap = getNameMap(kind, create);
if(nameMap != null){
return getMap(nameMap, name, create);
}
return null;
}
} }
public void clear() {
private HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>> getExclusionPatternsMap(int kind, String name, boolean create){
HashMap<String/*name*/, HashMap<HashSet<IPath>/*exclusionPatterns*/, HashMap<Integer/*flags*/, ICSettingEntry>>> nameMap = getNameMap(kind, create);
if(nameMap != null){
return getMap(nameMap, name, create);
}
return null;
}
private static <Key, K, V> HashMap<K, V> getMap(HashMap<Key, HashMap<K, V>> container, Key key, boolean create){
HashMap<K, V> map = container.get(key);
if(map == null && create){
map = new HashMap<K, V>();
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<Integer, ICSettingEntry> 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();
} }
} }

View file

@ -47,7 +47,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.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData; 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.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager; import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables; import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
@ -104,7 +103,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
private boolean fDataLoadded; private boolean fDataLoadded;
private boolean fInitializing; private boolean fInitializing;
private ICConfigurationDescription fBaseDescription; private ICConfigurationDescription fBaseDescription;
private CSettingEntryFactory fSettingsFactory;
private ICSourceEntry[] fResolvedSourceEntries; private ICSourceEntry[] fResolvedSourceEntries;
CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{ CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{
@ -123,7 +121,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
return fInitializing; return fInitializing;
} }
void loadData(CSettingEntryFactory factory) throws CoreException{ void loadData() throws CoreException{
if(fDataLoadded) if(fDataLoadded)
return; return;
@ -131,12 +129,8 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
fData = CProjectDescriptionManager.getInstance().loadData(this, null); fData = CProjectDescriptionManager.getInstance().loadData(this, null);
fSettingsFactory = factory;
copySettingsFrom(fData, true); copySettingsFrom(fData, true);
fSettingsFactory = null;
fSpecSettings.reconcileExtensionSettings(true); fSpecSettings.reconcileExtensionSettings(true);
((CBuildSettingCache)fBuildData).initEnvironmentCache(); ((CBuildSettingCache)fBuildData).initEnvironmentCache();
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
@ -167,7 +161,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
return fBaseCache; return fBaseCache;
} }
boolean applyData(CSettingEntryFactory factory, SettingsContext context) throws CoreException{ boolean applyData(SettingsContext context) throws CoreException{
boolean modified = true; boolean modified = true;
if(fBaseDescription != null){ if(fBaseDescription != null){
@ -175,7 +169,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
fDataLoadded = true; fDataLoadded = true;
fName = fData.getName(); fName = fData.getName();
fId = fData.getId(); fId = fData.getId();
fSettingsFactory = factory;
if((context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_SETTINGS_UNMODIFIED) == 0 || fBaseCache == null){ if((context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_SETTINGS_UNMODIFIED) == 0 || fBaseCache == null){
copySettingsFrom(fData, true); copySettingsFrom(fData, true);
@ -186,8 +179,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
modified = (context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_STORAGE_UNMODIFIED) == 0; modified = (context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_STORAGE_UNMODIFIED) == 0;
} }
fSettingsFactory = null;
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
fMacros = new StorableCdtVariables(vars, true); fMacros = new StorableCdtVariables(vars, true);
fSpecSettings.serialize(); fSpecSettings.serialize();
@ -201,10 +192,6 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
return modified; return modified;
} }
CSettingEntryFactory getSettingsFactory(){
return fSettingsFactory;
}
public StorableCdtVariables getCachedVariables(){ public StorableCdtVariables getCachedVariables(){
return fMacros; return fMacros;
} }

View file

@ -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.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData; 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.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
import org.eclipse.cdt.core.settings.model.util.EntryStore; import org.eclipse.cdt.core.settings.model.util.EntryStore;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -177,16 +176,9 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
} }
@Override @Override
protected ICLanguageSettingEntry[] processStoredEntries( protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op) {
ICLanguageSettingEntry[] entries, int op) { for(int i = 0; i < entries.length; i++) {
if(entries.length != 0){ entries[i] = CDataUtil.getPooledEntry(entries[i]);
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]);
}
}
} }
return entries; return entries;
} }

View file

@ -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.ICStorageElement;
import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; 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.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
@ -189,12 +188,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
if(!fIsReadOnly || !fIsLoading) if(!fIsReadOnly || !fIsLoading)
return; return;
CSettingEntryFactory factory = new CSettingEntryFactory();
for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){ for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
try { try {
cache.loadData(factory); cache.loadData();
factory.clear();
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
iter.remove(); iter.remove();
@ -210,14 +207,12 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
if(!fIsReadOnly || !fIsApplying) if(!fIsReadOnly || !fIsApplying)
return false; return false;
CSettingEntryFactory factory = new CSettingEntryFactory();
boolean modified = false; boolean modified = false;
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) { for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
try { try {
if(cache.applyData(factory, context)) if(cache.applyData(context))
modified = true; modified = true;
factory.clear();
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
e.printStackTrace(); e.printStackTrace();

View file

@ -86,7 +86,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.ICProjectConverter;
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFactory; 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.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.KindBasedStore;
import org.eclipse.cdt.core.settings.model.util.ListComparator; import org.eclipse.cdt.core.settings.model.util.ListComparator;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
@ -2325,11 +2324,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
ICStorageElement baseRootEl = settings.getRootStorageElement(); ICStorageElement baseRootEl = settings.getRootStorageElement();
rootEl = rootParent.importChild(baseRootEl); rootEl = rootParent.importChild(baseRootEl);
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, baseCache, cfgDes.getSpecSettings(), null, rootEl); CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, baseCache, cfgDes.getSpecSettings(), null, rootEl);
CSettingEntryFactory factory = new CSettingEntryFactory();
SettingsContext context = new SettingsContext(null); SettingsContext context = new SettingsContext(null);
cache.applyData(factory, context); cache.applyData(context);
cache.doneInitialization(); cache.doneInitialization();
factory.clear();
runContextOperations(context, null); runContextOperations(context, null);
return cache; return cache;
} }
@ -2404,10 +2401,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null); CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null);
CSettingEntryFactory factory = new CSettingEntryFactory(); cache.loadData();
cache.loadData(factory);
cache.doneInitialization(); cache.doneInitialization();
factory.clear();
return cache; return cache;
} }