1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45: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;
@ -31,14 +30,14 @@ public class PathInfoToLangSettingsConverter {
return ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.MACRO;
}
public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info){
return ICLanguageSettingEntry.INCLUDE_FILE
| ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.MACRO
| ICLanguageSettingEntry.MACRO_FILE;
}
public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){
switch (kind) {
case ICLanguageSettingEntry.INCLUDE_PATH:
@ -73,7 +72,7 @@ public class PathInfoToLangSettingsConverter {
}
return entries;
}
private static ICMacroEntry[] calculateEntries(int flags, Map<String, String> map){
ICMacroEntry entries[] = new ICMacroEntry[map.size()];
int num = 0;
@ -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

@ -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;
@ -221,8 +220,8 @@ public class BuildEntryStorage extends AbstractEntryStorage {
}
/**
* Return user entries (level 0)
*
* Return user entries (level 0)
*
* The UserEntryInfo[] is an array of all user entries from all the options
* applicable to the language setting entry kind.
* @param emptyValuesInfos list to which unresolved entries are added
@ -302,7 +301,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
}
/**
* Makes non-absolute paths relative to the build directory
* Makes non-absolute paths relative to the build directory
*/
private PathInfo fromBuildToProj(PathInfo info) {
if (info.isAbsolute())
@ -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;
@ -659,7 +658,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
* This method iterates over the passed in UserEntryInfo[]. The point of it is
* to collapse entries which are contained in a given UserEntry's sequence into a single
* UserEntryInfo.
*
*
* FIXME: As far as I can see info.fSequense only ever has a single entry in it...
* see UserEntryInfo constructor => this method doesn't accomplish anything useful
*/

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,29 +1,59 @@
/*******************************************************************************
* 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
* 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;
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,28 +1,59 @@
/*******************************************************************************
* 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
* 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;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath;
public final class CIncludePathEntry extends ACPathEntry implements ICIncludePathEntry{
public CIncludePathEntry(String value, int flags) {
super(value, flags);
/**
* 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 {
/**
* 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;
public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
/**
* 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,12 +275,39 @@ public class CDataUtil {
return path;
}
public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear){
/**
* 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));
}
public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flags){
switch (entry.getKind()){
/**
* 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:
entry = new CIncludePathEntry(entry.getName(), flags);
break;
@ -293,34 +333,94 @@ public class CDataUtil {
);
break;
}
return entry;
return (ICLanguageSettingEntry) getPooledEntry(entry);
}
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags){
/**
* 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();
}
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) {

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;
@ -41,9 +33,8 @@ public class LanguageSettingEntriesSerializer {
public static final String ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH = "srcRootPath"; //$NON-NLS-1$
public static final String ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING = "srcPrefixMapping"; //$NON-NLS-1$
// 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 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$
@ -64,31 +55,29 @@ public class LanguageSettingEntriesSerializer {
public static final String FLAGS_SEPARATOR = "|"; //$NON-NLS-1$
public static ICSettingEntry[] loadEntries(ICStorageElement el){
public static ICSettingEntry[] loadEntries(ICStorageElement el) {
return loadEntries(el, 0);
}
public static ICSettingEntry[] loadEntries(ICStorageElement el, int kindFilter){
public static ICSettingEntry[] loadEntries(ICStorageElement el, int kindFilter) {
List<ICSettingEntry> list = loadEntriesList(el, kindFilter);
return list.toArray(new ICSettingEntry[list.size()]);
}
public static List<ICSettingEntry> loadEntriesList(ICStorageElement el){
public static List<ICSettingEntry> loadEntriesList(ICStorageElement el) {
return loadEntriesList(el, 0);
}
public static List<ICSettingEntry> loadEntriesList(ICStorageElement el, int kindFilter){
public static List<ICSettingEntry> loadEntriesList(ICStorageElement el, int kindFilter) {
ICStorageElement children[] = el.getChildren();
ICStorageElement child;
List<ICSettingEntry> list = new ArrayList<ICSettingEntry>();
ICSettingEntry entry;
for(int i = 0; i < children.length; i++){
for (int i = 0; i < children.length; i++) {
child = children[i];
if(ELEMENT_ENTRY.equals(child.getName())){
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,51 +91,33 @@ public class LanguageSettingEntriesSerializer {
int flags = composeFlags(el.getAttribute(ATTRIBUTE_FLAGS));
String name = el.getAttribute(ATTRIBUTE_NAME);
String value = el.getAttribute(ATTRIBUTE_VALUE);
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);
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 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){
private static IPath loadPath(ICStorageElement el, String attr) {
String value = el.getAttribute(attr);
if(value != null)
if (value != null)
return new Path(value);
return null;
}
// private static void storePath(ICStorageElement el, String attr, IPath path){
// if(path != null)
// el.setAttribute(attr, path.toString());
// }
// private static void storePath(ICStorageElement el, String attr, IPath path){
// if(path != null)
// el.setAttribute(attr, path.toString());
// }
private static IPath[] loadExclusions(ICStorageElement el){
private static IPath[] loadExclusions(ICStorageElement el) {
String attr = el.getAttribute(ATTRIBUTE_EXCLUDING);
if(attr != null){
if (attr != null) {
String[] strs = CDataUtil.stringToArray(attr, FLAGS_SEPARATOR);
IPath[] paths = new IPath[strs.length];
for(int i = 0; i < strs.length; i++){
for (int i = 0; i < strs.length; i++) {
paths[i] = new Path(strs[i]);
}
return paths;
@ -154,12 +125,12 @@ public class LanguageSettingEntriesSerializer {
return null;
}
private static void storeExclusions(ICStorageElement el, IPath[] paths){
if(paths == null || paths.length == 0)
private static void storeExclusions(ICStorageElement el, IPath[] paths) {
if (paths == null || paths.length == 0)
return;
String[] strs = new String[paths.length];
for(int i = 0; i < strs.length; i++){
for (int i = 0; i < strs.length; i++) {
strs[i] = paths[i].toString();
}
@ -167,51 +138,51 @@ public class LanguageSettingEntriesSerializer {
el.setAttribute(ATTRIBUTE_EXCLUDING, attr);
}
public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element){
public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element) {
ICStorageElement child;
if(entries != null){
for(int i = 0; i < entries.length; i++){
if (entries != null) {
for (int i = 0; i < entries.length; i++) {
child = element.createChild(ELEMENT_ENTRY);
serializeEntry(entries[i], child);
}
}
}
public static void serializeEntry(ICSettingEntry entry, ICStorageElement element){
public static void serializeEntry(ICSettingEntry entry, ICStorageElement element) {
String kind = kindToString(entry.getKind());
String flags = composeFlagsString(entry.getFlags());
String name = entry.getName();
element.setAttribute(ATTRIBUTE_KIND, kind);
element.setAttribute(ATTRIBUTE_FLAGS, flags);
element.setAttribute(ATTRIBUTE_NAME, name);
switch(entry.getKind()){
switch (entry.getKind()) {
case ICSettingEntry.MACRO:
String value = entry.getValue();
element.setAttribute(ATTRIBUTE_VALUE, value);
break;
case ICSettingEntry.SOURCE_PATH:
case ICSettingEntry.OUTPUT_PATH:
IPath paths[] = ((ICExclusionPatternPathEntry)entry).getExclusionPatterns();
IPath paths[] = ((ICExclusionPatternPathEntry) entry).getExclusionPatterns();
storeExclusions(element, paths);
break;
case ICSettingEntry.LIBRARY_FILE:
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
ICLibraryFileEntry libFile = (ICLibraryFileEntry) entry;
IPath path = libFile.getSourceAttachmentPath();
if(path != null)
if (path != null)
element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_PATH, path.toString());
path = libFile.getSourceAttachmentRootPath();
if(path != null)
if (path != null)
element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH, path.toString());
path = libFile.getSourceAttachmentPrefixMapping();
if(path != null)
if (path != null)
element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING, path.toString());
}
}
public static String kindToString(int kind){
switch(kind){
public static String kindToString(int kind) {
switch (kind) {
case ICSettingEntry.INCLUDE_PATH:
return INCLUDE_PATH;
case ICSettingEntry.INCLUDE_FILE:
@ -232,64 +203,64 @@ public class LanguageSettingEntriesSerializer {
throw new IllegalArgumentException();
}
public static int stringToKind(String kind){
if(INCLUDE_PATH.equals(kind))
public static int stringToKind(String kind) {
if (INCLUDE_PATH.equals(kind))
return ICSettingEntry.INCLUDE_PATH;
if(INCLUDE_FILE.equals(kind))
if (INCLUDE_FILE.equals(kind))
return ICSettingEntry.INCLUDE_FILE;
if(MACRO.equals(kind))
if (MACRO.equals(kind))
return ICSettingEntry.MACRO;
if(MACRO_FILE.equals(kind))
if (MACRO_FILE.equals(kind))
return ICSettingEntry.MACRO_FILE;
if(LIBRARY_PATH.equals(kind))
if (LIBRARY_PATH.equals(kind))
return ICSettingEntry.LIBRARY_PATH;
if(LIBRARY_FILE.equals(kind))
if (LIBRARY_FILE.equals(kind))
return ICSettingEntry.LIBRARY_FILE;
if(SOURCE_PATH.equals(kind))
if (SOURCE_PATH.equals(kind))
return ICSettingEntry.SOURCE_PATH;
if(OUTPUT_PATH.equals(kind))
if (OUTPUT_PATH.equals(kind))
return ICSettingEntry.OUTPUT_PATH;
return 0;
// throw new UnsupportedOperationException();
// throw new UnsupportedOperationException();
}
public static String composeFlagsString(int flags){
public static String composeFlagsString(int flags) {
StringBuffer buf = new StringBuffer();
if((flags & ICSettingEntry.BUILTIN) != 0){
if ((flags & ICSettingEntry.BUILTIN) != 0) {
buf.append(BUILTIN);
}
if((flags & ICSettingEntry.READONLY) != 0){
if(buf.length() != 0)
if ((flags & ICSettingEntry.READONLY) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(READONLY);
}
if((flags & ICSettingEntry.LOCAL) != 0){
if(buf.length() != 0)
if ((flags & ICSettingEntry.LOCAL) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(LOCAL);
}
if((flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0){
if(buf.length() != 0)
if ((flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(VALUE_WORKSPACE_PATH);
}
if((flags & ICSettingEntry.RESOLVED) != 0){
if(buf.length() != 0)
if ((flags & ICSettingEntry.RESOLVED) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(RESOLVED);
}
if((flags & ICLanguageSettingEntry.UNDEFINED) != 0){
if(buf.length() != 0)
if ((flags & ICLanguageSettingEntry.UNDEFINED) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(UNDEFINED);
}
if((flags & ICLanguageSettingEntry.FRAMEWORKS_MAC) != 0){
if(buf.length() != 0)
if ((flags & ICLanguageSettingEntry.FRAMEWORKS_MAC) != 0) {
if (buf.length() != 0)
buf.append(FLAGS_SEPARATOR);
buf.append(FRAMEWORK);
@ -300,28 +271,28 @@ public class LanguageSettingEntriesSerializer {
/**
* @since 5.4
*/
public static int composeFlags(String flagsString){
if(flagsString == null || flagsString.length() == 0)
public static int composeFlags(String flagsString) {
if (flagsString == null || flagsString.length() == 0)
return 0;
StringTokenizer tokenizer = new StringTokenizer(flagsString, FLAGS_SEPARATOR);
int flags = 0;
String f;
while(tokenizer.hasMoreElements()){
while (tokenizer.hasMoreElements()) {
f = tokenizer.nextToken();
if(BUILTIN.equals(f))
flags |= ICSettingEntry.BUILTIN;
if(READONLY.equals(f))
flags |= ICSettingEntry.READONLY;
if(LOCAL.equals(f))
flags |= ICSettingEntry.LOCAL;
if(VALUE_WORKSPACE_PATH.equals(f))
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
if(RESOLVED.equals(f))
if (BUILTIN.equals(f))
flags |= ICSettingEntry.BUILTIN;
if (READONLY.equals(f))
flags |= ICSettingEntry.READONLY;
if (LOCAL.equals(f))
flags |= ICSettingEntry.LOCAL;
if (VALUE_WORKSPACE_PATH.equals(f))
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
if (RESOLVED.equals(f))
flags |= ICSettingEntry.RESOLVED;
if(UNDEFINED.equals(f))
if (UNDEFINED.equals(f))
flags |= ICSettingEntry.UNDEFINED;
if(FRAMEWORK.equals(f))
if (FRAMEWORK.equals(f))
flags |= ICSettingEntry.FRAMEWORKS_MAC;
}

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();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
path = value.getLocation();
}
IPath path = pathEntryValue.getFullPath();
if (path != null) {
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
} else {
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,28 +19,28 @@ 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;
/**
* A settings processor that imports and exports include paths.
*
*
* @author Mike Kucera
* @since 5.1
*
*
*/
public class IncludePathsSettingsProcessor extends SettingsProcessor {
public class IncludePathsSettingsProcessor extends SettingsProcessor {
private static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; //$NON-NLS-1$
private static final String INCLUDE_PATH_ELEMENT = "includepath"; //$NON-NLS-1$
private static final String WORKSPACE_PATH_ATTR = "workspace_path"; //$NON-NLS-1$
@Override
public Image getIcon() {
return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER));
@ -50,7 +50,7 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
public String getDisplayName() {
return Messages.ProjectSettingsWizardPage_Processor_Includes;
}
@Override
public String getSectionName() {
return SECTION_NAME;
@ -60,11 +60,11 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
protected int getSettingsType() {
return ICSettingEntry.INCLUDE_PATH;
}
@Override
protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
char[] value = setting.getValue().toCharArray();
try {
AttributesImpl attrib = null;
if( (setting.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) > 0 ) {
@ -75,17 +75,17 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
content.characters(value, 0, value.length);
content.endElement(NONE, NONE, INCLUDE_PATH_ELEMENT);
newline(content);
} catch (SAXException e) {
throw new SettingsImportExportException(e);
}
}
@Override
protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();
List<Element> includeNodes = XMLUtils.extractChildElements(language, INCLUDE_PATH_ELEMENT);
for(Element includeElement : includeNodes) {
String include = includeElement.getTextContent();
@ -93,13 +93,13 @@ 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));
}
}
if(includes.isEmpty())
return;
// need to do this or existing settings will disappear
includes.addAll(setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH));
setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes);

View file

@ -22,29 +22,29 @@ 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;
/**
* A settings processor that imports and exports symbols.
*
*
* @author Mike Kucera
* @since 5.1
*
*
*/
public class MacroSettingsProcessor extends SettingsProcessor {
public static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; //$NON-NLS-1$
private static final String MACRO_ELEMENT = "macro"; //$NON-NLS-1$
private static final String NAME_ELEMENT = "name"; //$NON-NLS-1$
private static final String VALUE_ELEMENT = "value"; //$NON-NLS-1$
@Override
public Image getIcon() {
return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
@ -64,44 +64,44 @@ public class MacroSettingsProcessor extends SettingsProcessor {
protected int getSettingsType() {
return ICSettingEntry.MACRO;
}
@Override
protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
char[] name = setting.getName().toCharArray();
char[] value = setting.getValue().toCharArray();
try {
content.startElement(NONE, NONE, MACRO_ELEMENT, null);
newline(content);
content.startElement(NONE, NONE, NAME_ELEMENT, null);
content.characters(name, 0, name.length);
content.endElement(NONE, NONE, NAME_ELEMENT);
content.startElement(NONE, NONE, VALUE_ELEMENT, null);
content.characters(value, 0, value.length);
content.endElement(NONE, NONE, VALUE_ELEMENT);
newline(content);
content.endElement(NONE, NONE, MACRO_ELEMENT);
newline(content);
} catch(SAXException e) {
throw new SettingsImportExportException(e);
}
}
@Override
protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
List<ICLanguageSettingEntry> macros = new ArrayList<ICLanguageSettingEntry>();
List<Element> macrosNodes = XMLUtils.extractChildElements(language, MACRO_ELEMENT);
for(Element macroElement : macrosNodes) {
String name = null;
String value = null;
NodeList nodeList = macroElement.getChildNodes();
for(int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
@ -125,21 +125,21 @@ public class MacroSettingsProcessor extends SettingsProcessor {
throw new SettingsImportExportException("Unknown node: " + node.getNodeName()); //$NON-NLS-1$
}
}
if(name == null)
throw new SettingsImportExportException("There must be one <name> element"); //$NON-NLS-1$
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())
return;
// need to do this or existing settings will disappear
macros.addAll(setting.getSettingEntriesList(ICSettingEntry.MACRO));
setting.setSettingEntries(ICSettingEntry.MACRO, macros);
}
}

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,26 +10,26 @@
*******************************************************************************/
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.
*/
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
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
@Override
public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
@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,14 +22,14 @@ 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
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
@Override
public int getKind() { return ICSettingEntry.MACRO; }
@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;
@ -40,13 +40,13 @@ public class IncludeFileTab extends AbstractLangsListTab {
@Override
public void additionalTableSet() {
columnToFit = new TableColumn(table, SWT.NONE);
columnToFit.setText(Messages.IncludeFileTab_0);
columnToFit.setToolTipText(Messages.IncludeFileTab_0);
columnToFit.setText(Messages.IncludeFileTab_0);
columnToFit.setToolTipText(Messages.IncludeFileTab_0);
showBIButton.setSelection(true);
table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = Messages.IncludeFileTab_0;
e.result = Messages.IncludeFileTab_0;
}
});
}
@ -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;
}
@ -78,7 +78,7 @@ public class IncludeFileTab extends AbstractLangsListTab {
IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(),
IncludeDialog.OLD_FILE,
Messages.IncludeFileTab_2,
Messages.IncludeFileTab_2,
ent.getValue(),
getResDesc().getConfiguration(),
ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
@ -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;
@ -27,28 +27,28 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* @noextend This class is not intended to be subclassed by clients.
*/
public class IncludeTab extends AbstractLangsListTab {
@Override
public void additionalTableSet() {
columnToFit = new TableColumn(table, SWT.NONE);
columnToFit.setText(Messages.IncludeTab_0);
columnToFit.setToolTipText(Messages.IncludeTab_0);
columnToFit.setText(Messages.IncludeTab_0);
columnToFit.setToolTipText(Messages.IncludeTab_0);
showBIButton.setSelection(true);
table.getAccessible().addAccessibleListener(
new AccessibleAdapter() {
new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = Messages.IncludeTab_0;
e.result = Messages.IncludeTab_0;
}
}
);
}
@Override
public ICLanguageSettingEntry doAdd() {
IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(), IncludeDialog.NEW_DIR,
Messages.IncludeTab_1,
Messages.IncludeTab_1,
EMPTY_STR, getResDesc().getConfiguration(), 0);
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
toAllCfgs = dlg.check1;
@ -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;
}
@ -66,21 +66,21 @@ public void additionalTableSet() {
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(), IncludeDialog.OLD_DIR,
Messages.IncludeTab_2,
Messages.IncludeTab_2,
ent.getValue(), getResDesc().getConfiguration(),
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
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;
}
@Override
public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
@Override
public void createControls(final Composite parent) {
super.createControls(parent);

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;
@ -33,18 +33,18 @@ public class SymbolTab extends AbstractLangsListTab {
@Override
public void additionalTableSet() {
TableColumn tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.SymbolTab_0);
tc.setText(Messages.SymbolTab_0);
tc.setWidth(80);
tc.setToolTipText(Messages.SymbolTab_0);
tc.setToolTipText(Messages.SymbolTab_0);
tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.SymbolTab_1);
tc.setText(Messages.SymbolTab_1);
tc.setWidth(130);
tc.setToolTipText(Messages.SymbolTab_1);
tc.setToolTipText(Messages.SymbolTab_1);
table.getAccessible().addAccessibleListener(
new AccessibleAdapter() {
new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = Messages.SymbolTab_0;
e.result = Messages.SymbolTab_0;
}
}
);
@ -54,11 +54,11 @@ public class SymbolTab extends AbstractLangsListTab {
public ICLanguageSettingEntry doAdd() {
SymbolDialog dlg = new SymbolDialog(
usercomp.getShell(), true,
Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc());
Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc());
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;
}
@ -67,16 +67,16 @@ public class SymbolTab extends AbstractLangsListTab {
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
SymbolDialog dlg = new SymbolDialog(
usercomp.getShell(), false,
Messages.SymbolTab_3, ent.getName(),
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;
}
@Override
public int getKind() {
return ICSettingEntry.MACRO;
public int getKind() {
return ICSettingEntry.MACRO;
}
// Specific version of "update()" for Symbols tab only
@ -84,21 +84,21 @@ public class SymbolTab extends AbstractLangsListTab {
public void update() {
if (lang != null) {
int x = table.getSelectionIndex();
if (x == -1)
if (x == -1)
x = 0;
shownEntries = getIncs();
Collections.sort(shownEntries, CDTListComparator.getInstance());
tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
if (table.getItemCount() > x)
table.setSelection(x);
else if (table.getItemCount() > 0)
else if (table.getItemCount() > 0)
table.setSelection(0);
}
}
updateStringListModeControl();
updateButtons();
}
@Override
public void createControls(final Composite parent) {
super.createControls(parent);

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);
}
}