1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

bug 290631: Caching of ICSettingEntry objects in CDataUtil.

This commit is contained in:
Andrew Gvozdev 2012-01-27 14:30:06 -05:00
parent 453f71f4c4
commit 4fc55d2d21
21 changed files with 861 additions and 694 deletions

View file

@ -14,7 +14,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICMacroEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
@ -81,7 +80,7 @@ public class PathInfoToLangSettingsConverter {
for (Entry<String, String> entry : entrySet) {
String name = entry.getKey();
String value = entry.getValue();
entries[num++] = new CMacroEntry(name, value, flags);
entries[num++] = CDataUtil.createCMacroEntry(name, value, flags);
}
return entries;
}

View file

@ -27,7 +27,6 @@ import java.util.Vector;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
@ -2797,7 +2796,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
List<ICSettingEntry> list = new ArrayList<ICSettingEntry>(entries.length + 1);
// Add project level include path
list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
list.add(CDataUtil.createCIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
// Add Build output path as an exported library path
entries = CDataUtil.resolveEntries(entries, des);

View file

@ -33,11 +33,9 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -611,11 +609,11 @@ public class HeadlessBuilder implements IApplication {
macroVal = macro.substring(macro.indexOf('=') + 1);
macro = macro.substring(0, macro.indexOf('='));
}
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CMacroEntry(macro, macroVal, 0));
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCMacroEntry(macro, macroVal, 0));
} else if ("-I".equals(args[i])) { //$NON-NLS-1$
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludePathEntry(args[++i], 0));
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCIncludePathEntry(args[++i], 0));
} else if ("-include".equals(args[i])) { //$NON-NLS-1$
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludeFileEntry(args[++i], 0));
HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCIncludeFileEntry(args[++i], 0));
} else if ("-E".equals(args[i])) { //$NON-NLS-1$
addEnvironmentVariable(args[++i], IEnvironmentVariable.ENVVAR_REPLACE);
} else if ("-Ea".equals(args[i])) { //$NON-NLS-1$

View file

@ -19,7 +19,6 @@ import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
@ -397,7 +396,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
if (kind == ICSettingEntry.MACRO) {
String nv[] = macroNameValueFromValue(optionValue.getValue());
return new CMacroEntry(nv[0], nv[1], flags);
return CDataUtil.createCMacroEntry(nv[0], nv[1], flags);
}
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;

View file

@ -20,6 +20,13 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry
// IPath fLocation;
// private IPath fPath;
/**
* Constructor.
*
* @param rc - a resource in the workspace.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
* If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied.
*/
ACPathEntry(IResource rc, int flags) {
super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH);
// fFullPath = rc.getFullPath();
@ -33,10 +40,25 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry
fFullPath = fullPath;
}
*/
ACPathEntry(String value, int flags) {
super(value, flags);
/**
* Constructor.
*
* @param name - resource path. The path can be an absolute location on the local file-system
* or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
ACPathEntry(String name, int flags) {
super(name, flags);
}
/**
* Constructor.
*
* @param path - resource path. The path can be an absolute location on the local
* file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
ACPathEntry(IPath path, int flags) {
super(path.toString(), flags /*| RESOLVED*/);
// fPath = path;

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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,17 +13,47 @@ package org.eclipse.cdt.core.settings.model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
public final class CIncludeFileEntry extends ACPathEntry implements
ICIncludeFileEntry {
public CIncludeFileEntry(String value, int flags) {
super(value, flags);
/**
* Representation in the project model of include file settings entries.
* As an example, those are supplied by a gcc compiler with option "-include".
*/
public final class CIncludeFileEntry extends ACPathEntry implements ICIncludeFileEntry {
/**
* This constructor is discouraged to be referenced by clients.
*
* Instead, use pooled entries with CDataUtil.createCIncludeFileEntry(name, flags).
*
* @param name - include file path. The path can be an absolute location on the local file-system
* or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CIncludeFileEntry(String name, int flags) {
super(name, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries with CDataUtil.createCIncludeFileEntry(location.toString(), flags)
* or wrap it with CDataUtil.getPooledEntry(new CIncludeFileEntry(location, flags)).
*
* @param location - include file path. The path can be an absolute location on the local
* file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CIncludeFileEntry(IPath location, int flags) {
super(location, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CIncludeFileEntry(rc, flags)).
*
* @param rc - include file as a resource in the workspace.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
* If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied.
*/
public CIncludeFileEntry(IFile rc, int flags) {
super(rc, flags);
}

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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,16 +13,47 @@ package org.eclipse.cdt.core.settings.model;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath;
/**
* Representation in the project model of include path settings entries.
* As an example, those are supplied by a gcc compiler with option "-I".
*/
public final class CIncludePathEntry extends ACPathEntry implements ICIncludePathEntry {
public CIncludePathEntry(String value, int flags) {
super(value, flags);
/**
* This constructor is discouraged to be referenced by clients.
*
* Instead, use pooled entries with CDataUtil.createCIncludePathEntry(name, flags).
*
* @param name - include path. The path can be an absolute location on the local file-system
* or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CIncludePathEntry(String name, int flags) {
super(name, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries with CDataUtil.createCIncludePathEntry(location.toString(), flags)
* or wrap it with CDataUtil.getPooledEntry(new CIncludePathEntry(location, flags)).
*
* @param location - include path. The path can be an absolute location on the local
* file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CIncludePathEntry(IPath location, int flags) {
super(location, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CIncludePathEntry(rc, flags)).
*
* @param rc - include path as a resource in the workspace.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
* If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied.
*/
public CIncludePathEntry(IFolder rc, int flags) {
super(rc, flags);
}

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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,11 +12,22 @@ package org.eclipse.cdt.core.settings.model;
import org.eclipse.cdt.internal.core.SafeStringInterner;
/**
* Representation in the project model of macro settings entries.
* As an example, those are supplied by a gcc compiler with option "-D".
*/
public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry {
private String fValue;
/**
* This constructor is discouraged to be referenced by clients.
*
* Instead, use pooled entries with CDataUtil.createCMacroEntry(name, value, flags).
*
* @param name - name of the macro.
* @param value - value of the macro.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CMacroEntry(String name, String value, int flags) {
super(name, flags);
fValue = SafeStringInterner.safeIntern(value);

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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,17 +13,48 @@ package org.eclipse.cdt.core.settings.model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
public final class CMacroFileEntry extends ACPathEntry implements
ICMacroFileEntry {
/**
* Representation in the project model of include file settings entries.
* As an example, those are supplied by a gcc compiler with option "-imacros".
*/
public final class CMacroFileEntry extends ACPathEntry implements ICMacroFileEntry {
public CMacroFileEntry(String value, int flags) {
super(value, flags);
/**
* This constructor is discouraged to be referenced by clients.
*
* Instead, use pooled entries with CDataUtil.createCMacroFileEntry(name, flags).
*
* @param name - macro file path. The path can be an absolute location on the local file-system
* or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CMacroFileEntry(String name, int flags) {
super(name, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries with CDataUtil.createCMacroFileEntry(location.toString(), flags)
* or wrap it with CDataUtil.getPooledEntry(new CMacroFileEntry(location, flags)).
*
* @param location - macro file path. The path can be an absolute location on the local
* file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/
public CMacroFileEntry(IPath location, int flags) {
super(location, flags);
}
/**
* This constructor is discouraged to be used directly.
*
* Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CMacroFileEntry(rc, flags)).
*
* @param rc - macro file as a resource in the workspace.
* @param flags - bitwise combination of {@link ICSettingEntry} flags.
* If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied.
*/
public CMacroFileEntry(IFile rc, int flags) {
super(rc, flags);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 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
@ -57,6 +57,7 @@ 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.CDataFactory;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
import org.eclipse.cdt.internal.core.parser.util.WeakHashSet;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
@ -76,6 +77,18 @@ public class CDataUtil {
private static Random randomNumber;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
/**
* Pool of setting entries implemented as WeakHashSet. That allows to gain memory savings
* at the expense of CPU time. WeakHashSet handles garbage collection when a list is not
* referenced anywhere else. See JavaDoc {@link java.lang.ref.WeakReference} about weak reference objects.
*/
private static WeakHashSet<ICSettingEntry> settingEntriesPool = new WeakHashSet<ICSettingEntry>() {
@Override
public synchronized ICSettingEntry add(ICSettingEntry entry) {
return super.add(entry);
}
};
public static int genRandomNumber(){
if (randomNumber == null) {
// Set the random number seed
@ -262,10 +275,37 @@ public class CDataUtil {
return path;
}
/**
* Return entry cached in setting entries pool to optimize for memory usage.
* Note that the pool will handle garbage collection for unreferenced entries.
*
* @since 5.4
*/
public static ICSettingEntry getPooledEntry(ICSettingEntry entry) {
return settingEntriesPool.add(entry);
}
/**
* Convenience method to clone {@link ICLanguageSettingEntry} with modified flags.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @param entry - source entry.
* @param flagsToAdd - binary combination of bits to add to the flags.
* @param flafsToClear - binary combination of bits to clear in the flags.
* @return new entry with the modified flags.
*/
public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear) {
return createEntry(entry, (entry.getFlags() | flagsToAdd) & (~flafsToClear));
}
/**
* Convenience method to clone {@link ICLanguageSettingEntry} with different flags.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @param entry - source entry.
* @param flags - new flags.
* @return new entry with the specified flags.
*/
public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flags) {
switch (entry.getKind()) {
case ICSettingEntry.INCLUDE_PATH:
@ -293,35 +333,95 @@ public class CDataUtil {
);
break;
}
return entry;
return (ICLanguageSettingEntry) getPooledEntry(entry);
}
/**
* Convenience method to create {@link ICLanguageSettingEntry} depending on kind.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* Note that the method always returns {@link ICLanguageSettingEntry}.
*/
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags) {
return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null);
}
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){
/**
* Convenience method to create {@link ICSettingEntry} depending on kind.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*/
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) {
ICSettingEntry entry = null;
switch (kind){
case ICSettingEntry.INCLUDE_PATH:
return new CIncludePathEntry(name, flags);
case ICSettingEntry.MACRO:
return new CMacroEntry(name, value, flags);
case ICSettingEntry.INCLUDE_FILE:
return new CIncludeFileEntry(name, flags);
case ICSettingEntry.MACRO_FILE:
return new CMacroFileEntry(name, flags);
case ICSettingEntry.LIBRARY_PATH:
return new CLibraryPathEntry(name, flags);
case ICSettingEntry.LIBRARY_FILE:
return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping);
case ICSettingEntry.OUTPUT_PATH:
return new COutputEntry(name, exclusionPatterns, flags);
case ICSettingEntry.SOURCE_PATH:
return new CSourceEntry(name, exclusionPatterns, flags);
}
case ICLanguageSettingEntry.INCLUDE_PATH:
entry = new CIncludePathEntry(name, flags);
break;
case ICLanguageSettingEntry.MACRO:
entry = new CMacroEntry(name, value, flags);
break;
case ICLanguageSettingEntry.INCLUDE_FILE:
entry = new CIncludeFileEntry(name, flags);
break;
case ICLanguageSettingEntry.MACRO_FILE:
entry = new CMacroFileEntry(name, flags);
break;
case ICLanguageSettingEntry.LIBRARY_PATH:
entry = new CLibraryPathEntry(name, flags);
break;
case ICLanguageSettingEntry.LIBRARY_FILE:
entry = new CLibraryFileEntry(name, flags, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
break;
case ICLanguageSettingEntry.OUTPUT_PATH:
entry = new COutputEntry(name, exclusionPatterns, flags);
break;
case ICLanguageSettingEntry.SOURCE_PATH:
entry = new CSourceEntry(name, exclusionPatterns, flags);
break;
default:
throw new IllegalArgumentException();
}
return getPooledEntry(entry);
}
/**
* Utility method to create {@link CIncludePathEntry}.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @since 5.4
*/
public static CIncludePathEntry createCIncludePathEntry(String name, int flags) {
return (CIncludePathEntry) getPooledEntry(new CIncludePathEntry(name, flags));
}
/**
* Utility method to create {@link CIncludeFileEntry}.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @since 5.4
*/
public static CIncludeFileEntry createCIncludeFileEntry(String name, int flags) {
return (CIncludeFileEntry) getPooledEntry(new CIncludeFileEntry(name, flags));
}
/**
* Utility method to create {@link CMacroEntry}.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @since 5.4
*/
public static CMacroEntry createCMacroEntry(String name, String value, int flags) {
return (CMacroEntry) getPooledEntry(new CMacroEntry(name, value, flags));
}
/**
* Utility method to create {@link CMacroFileEntry}.
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
*
* @since 5.4
*/
public static CMacroFileEntry createCMacroFileEntry(String name, int flags) {
return (CMacroFileEntry) getPooledEntry(new CMacroFileEntry(name, flags));
}
public static String[] getSourceExtensions(IProject project, CLanguageData data) {
String[] exts = null;

View file

@ -14,14 +14,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
import org.eclipse.cdt.core.settings.model.COutputEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
@ -44,7 +36,6 @@ public class LanguageSettingEntriesSerializer {
// public static final String ATTRIBUTE_FULL_PATH = "fullPath"; //$NON-NLS-1$
// public static final String ATTRIBUTE_LOCATION = "location"; //$NON-NLS-1$
public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
public static final String INCLUDE_FILE = "includeFile"; //$NON-NLS-1$
public static final String MACRO = "macro"; //$NON-NLS-1$
@ -86,9 +77,7 @@ public class LanguageSettingEntriesSerializer {
child = children[i];
if (ELEMENT_ENTRY.equals(child.getName())) {
entry = loadEntry(child);
if(entry != null
&& (kindFilter == 0
|| (kindFilter & entry.getKind()) != 0))
if (entry != null && (kindFilter == 0 || (kindFilter & entry.getKind()) != 0))
list.add(entry);
}
}
@ -102,31 +91,13 @@ public class LanguageSettingEntriesSerializer {
int flags = composeFlags(el.getAttribute(ATTRIBUTE_FLAGS));
String name = el.getAttribute(ATTRIBUTE_NAME);
switch(kind){
case ICSettingEntry.INCLUDE_PATH:
return new CIncludePathEntry(name, flags);
case ICSettingEntry.INCLUDE_FILE:
return new CIncludeFileEntry(name, flags);
case ICSettingEntry.MACRO:
String value = el.getAttribute(ATTRIBUTE_VALUE);
return new CMacroEntry(name, value, flags);
case ICSettingEntry.MACRO_FILE:
return new CMacroFileEntry(name, flags);
case ICSettingEntry.LIBRARY_PATH:
return new CLibraryPathEntry(name, flags);
case ICSettingEntry.LIBRARY_FILE:
IPath srcPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PATH);
IPath srcRootPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH);
IPath[] exclusionPatterns = loadExclusions(el);
IPath srcPrefixMapping = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING);
return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping);
case ICSettingEntry.OUTPUT_PATH:
return new COutputEntry(name, loadExclusions(el), flags);
case ICSettingEntry.SOURCE_PATH:
return new CSourceEntry(name, loadExclusions(el), flags);
}
return null;
return CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags, srcPath, srcRootPath, srcPrefixMapping);
}
private static IPath loadPath(ICStorageElement el, String attr) {

View file

@ -40,11 +40,6 @@ import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.core.settings.model.CExternalSetting;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
import org.eclipse.cdt.core.settings.model.COutputEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -301,25 +296,28 @@ public class PathEntryTranslator {
}
private static ICLanguageSettingEntry createLangEntry(ResolvedEntry entry) {
PathEntryValueInfo value = entry.getResolvedValue();
PathEntryValueInfo pathEntryValue = entry.getResolvedValue();
String name = pathEntryValue.getName();
int flags = ICSettingEntry.RESOLVED;
if (entry.isReadOnly())
flags |= ICSettingEntry.READONLY;
if (entry.isBuiltIn())
flags |= ICSettingEntry.BUILTIN;
switch (entry.fEntry.getEntryKind()) {
case IPathEntry.CDT_LIBRARY:{
ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry;
IPath path = value.getFullPath();
IPath path = pathEntryValue.getFullPath();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
path = value.getLocation();
path = pathEntryValue.getLocation();
}
int kind = entry.fEntry.getEntryKind();
switch (kind) {
case IPathEntry.CDT_LIBRARY:{
if (path != null) {
return new CLibraryFileEntry(value.getName(), flags,
ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry;
return (ICLanguageSettingEntry) CDataUtil.createEntry(ICSettingEntry.LIBRARY_FILE, name, null, null, flags,
libEntry.getSourceAttachmentPath(),
libEntry.getSourceAttachmentRootPath(),
libEntry.getSourceAttachmentPrefixMapping());
@ -331,52 +329,30 @@ public class PathEntryTranslator {
// case IPathEntry.CDT_SOURCE:
// return INDEX_CDT_SOURCE;
case IPathEntry.CDT_INCLUDE:{
IPath path = value.getFullPath();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
path = value.getLocation();
}
if (path != null) {
return new CIncludePathEntry(value.getName(), flags);
return CDataUtil.createCIncludePathEntry(name, flags);
}
break;
}
// case IPathEntry.CDT_CONTAINER:
// return INDEX_CDT_CONTAINER;
case IPathEntry.CDT_MACRO:
String name = value.getName();
if (name.length() != 0) {
String mValue = value.getValue();
return new CMacroEntry(name, mValue, flags);
String value = pathEntryValue.getValue();
return CDataUtil.createCMacroEntry(name, value, flags);
}
break;
// case IPathEntry.CDT_OUTPUT:
// return INDEX_CDT_OUTPUT;
case IPathEntry.CDT_INCLUDE_FILE:{
IPath path = value.getFullPath();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
path = value.getLocation();
}
if (path != null) {
return new CIncludeFileEntry(value.getName(), flags);
return CDataUtil.createCIncludeFileEntry(name, flags);
}
break;
}
case IPathEntry.CDT_MACRO_FILE:{
IPath path = value.getFullPath();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
path = value.getLocation();
}
if (path != null) {
return new CMacroFileEntry(value.getName(), flags);
return CDataUtil.createCMacroFileEntry(name, flags);
}
break;
}

View file

@ -19,10 +19,10 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
@ -93,7 +93,7 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
if(include != null && include.length() > 0) {
if( includeElement.getAttribute(WORKSPACE_PATH_ATTR).equalsIgnoreCase(Boolean.TRUE.toString()) )
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
includes.add(new CIncludePathEntry(include, flags));
includes.add(CDataUtil.createCIncludePathEntry(include, flags));
}
}

View file

@ -22,10 +22,10 @@ import org.w3c.dom.Text;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
@ -131,7 +131,7 @@ public class MacroSettingsProcessor extends SettingsProcessor {
if(value == null)
throw new SettingsImportExportException("There must be one <value> element"); //$NON-NLS-1$
macros.add(new CMacroEntry(name, value, 0));
macros.add(CDataUtil.createCMacroEntry(name, value, 0));
}
if(macros.isEmpty())

View file

@ -11,9 +11,9 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
/**
* @noextend This class is not intended to be subclassed by clients.
@ -25,7 +25,7 @@ public class ExpIncludeFileTab extends AbstractExportTab {
@Override
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
return new CIncludeFileEntry(s2, flags);
return CDataUtil.createCIncludeFileEntry(s2, flags);
}
@Override

View file

@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
/**
* @noextend This class is not intended to be subclassed by clients.
@ -22,7 +22,7 @@ public class ExpIncludeTab extends AbstractExportTab {
@Override
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
return new CIncludePathEntry(s2, flags);
return CDataUtil.createCIncludePathEntry(s2, flags);
}
@Override

View file

@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
/**
* @noextend This class is not intended to be subclassed by clients.
@ -22,7 +22,7 @@ public class ExpSymbolTab extends AbstractExportTab {
// isWsp is ignored for symbols
@Override
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
return new CMacroEntry(s1, s2, 0);
return CDataUtil.createCMacroEntry(s1, s2, 0);
}
@Override

View file

@ -18,9 +18,9 @@ import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.ui.newui.Messages;
@ -68,7 +68,7 @@ public class IncludeFileTab extends AbstractLangsListTab {
if (dlg.check2) { // isWsp
flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
}
return new CIncludeFileEntry(dlg.text1, flags);
return CDataUtil.createCIncludeFileEntry(dlg.text1, flags);
}
return null;
}
@ -87,7 +87,7 @@ public class IncludeFileTab extends AbstractLangsListTab {
int flags = 0;
if (dlg.check2)
flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CIncludeFileEntry(dlg.text1, flags);
return CDataUtil.createCIncludeFileEntry(dlg.text1, flags);
}
return null;
}

View file

@ -17,9 +17,9 @@ import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.ui.newui.Messages;
@ -57,7 +57,7 @@ public void additionalTableSet() {
if (dlg.check2) { // isWsp
flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
}
return new CIncludePathEntry(dlg.text1, flags);
return CDataUtil.createCIncludePathEntry(dlg.text1, flags);
}
return null;
}
@ -72,7 +72,7 @@ public void additionalTableSet() {
if (dlg.open()) {
int flags = 0;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CIncludePathEntry(dlg.text1, flags);
return CDataUtil.createCIncludePathEntry(dlg.text1, flags);
}
return null;
}

View file

@ -20,9 +20,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.cdt.core.model.util.CDTListComparator;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.ui.newui.Messages;
@ -58,7 +58,7 @@ public class SymbolTab extends AbstractLangsListTab {
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
return new CMacroEntry(dlg.text1, dlg.text2, 0);
return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0);
}
return null;
}
@ -70,7 +70,7 @@ public class SymbolTab extends AbstractLangsListTab {
Messages.SymbolTab_3, ent.getName(),
ent.getValue(), getResDesc());
if (dlg.open())
return new CMacroEntry(dlg.text1, dlg.text2, 0);
return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0);
return null;
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
@ -196,7 +197,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
// if we didn't find the path, add it
if(!symbolFound) {
entriesChanged = true;
CMacroEntry newEntry = new CMacroEntry(symbol, discSymbols.get(symbol), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
CMacroEntry newEntry = CDataUtil.createCMacroEntry(symbol, discSymbols.get(symbol), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
newEntries.add(newEntry);
}
}
@ -216,7 +217,6 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
newEntries.add(entry);
}
boolean entriesChanged = false;
// look for settings corresponding to each path we discovered
@ -234,7 +234,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
// if we didn't find the path, add it
if(!pathFound) {
entriesChanged = true;
CIncludePathEntry newEntry = new CIncludePathEntry(path, ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
CIncludePathEntry newEntry = CDataUtil.createCIncludePathEntry(path.toString(), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
newEntries.add(newEntry);
}
}