mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
bug 290631: Caching of ICSettingEntry objects in CDataUtil -
CLibraryPathEntry/CLibraryFileEntry.
This commit is contained in:
parent
433e8e34c6
commit
e16fe328eb
8 changed files with 110 additions and 31 deletions
|
@ -27,8 +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.CLibraryFileEntry;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||
|
@ -1487,8 +1485,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
if (canExportedArtifactInfo()) {
|
||||
// Remove existing exported library, if it exists
|
||||
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
|
||||
ICSettingEntry[] libs = CDataUtil.resolveEntries(new ICSettingEntry[] {
|
||||
new CLibraryFileEntry(getArtifactName(), 0)}, des);
|
||||
ICSettingEntry[] unresolved = new ICSettingEntry[] {CDataUtil.createCLibraryFileEntry(getArtifactName(), 0)};
|
||||
ICSettingEntry[] libs = CDataUtil.resolveEntries(unresolved, des);
|
||||
if (libs.length > 0) {
|
||||
for (ICExternalSetting setting : des.getExternalSettings()) {
|
||||
Set<ICSettingEntry> entries = new LinkedHashSet<ICSettingEntry>(Arrays.asList(setting.getEntries()));
|
||||
|
@ -2807,14 +2805,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
IPath p = new Path(value);
|
||||
if(!p.isAbsolute())
|
||||
value = getOwner().getFullPath().append(value).toString();
|
||||
ICLibraryPathEntry lib = new CLibraryPathEntry(value, out.getFlags() & (~ICSettingEntry.RESOLVED));
|
||||
ICLibraryPathEntry lib = CDataUtil.createCLibraryPathEntry(value, out.getFlags() & (~ICSettingEntry.RESOLVED));
|
||||
list.add(lib);
|
||||
}
|
||||
|
||||
// Add 'libs' artifact names themselves
|
||||
ICSettingEntry[] libFile = new ICSettingEntry[] {new CLibraryFileEntry(getArtifactName(), 0)};
|
||||
libFile = CDataUtil.resolveEntries(libFile, des);
|
||||
list.add(libFile[0]);
|
||||
ICSettingEntry[] unresolved = new ICSettingEntry[] {CDataUtil.createCLibraryFileEntry(getArtifactName(), 0)};
|
||||
ICSettingEntry[] libFiles = CDataUtil.resolveEntries(unresolved, des);
|
||||
list.add(libFiles[0]);
|
||||
|
||||
// Contribute the settings back as 'exported'
|
||||
des.createExternalSetting(null, null, null, list.toArray(new ICSettingEntry[list.size()]));
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2009 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2012 Intel Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.settings.model;
|
||||
|
||||
|
@ -15,20 +15,51 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public final class CLibraryFileEntry extends ACPathEntry implements
|
||||
ICLibraryFileEntry {
|
||||
/**
|
||||
* Representation in the project model of library file settings entries.
|
||||
* As an example, those are supplied by a gcc compiler with option "-l".
|
||||
*/
|
||||
public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFileEntry {
|
||||
private IPath fSourceAttachmentPath;
|
||||
private IPath fSourceAttachmentRootPath;
|
||||
private IPath fSourceAttachmentPrefixMapping;
|
||||
|
||||
public CLibraryFileEntry(String value, int flags) {
|
||||
this(value, flags, null, null, null);
|
||||
/**
|
||||
* This constructor is discouraged to be referenced by clients.
|
||||
*
|
||||
* Instead, use pooled entries with CDataUtil.createCLibraryFileEntry(name, flags).
|
||||
*
|
||||
* @param name - library 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 CLibraryFileEntry(String name, int flags) {
|
||||
this(name, flags, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is discouraged to be used directly.
|
||||
*
|
||||
* Instead, use pooled entries with CDataUtil.createCLibraryFileEntry(location.toString(), flags)
|
||||
* or wrap it with CDataUtil.getPooledEntry(new CLibraryFileEntry(location, flags)).
|
||||
*
|
||||
* @param location - library 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 CLibraryFileEntry(IPath location, int flags) {
|
||||
this(location, flags, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is discouraged to be used directly.
|
||||
*
|
||||
* Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CLibraryFileEntry(rc, flags)).
|
||||
*
|
||||
* @param rc - library 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 CLibraryFileEntry(IFile rc, int flags) {
|
||||
this(rc, flags, null, null, null);
|
||||
}
|
||||
|
|
|
@ -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.IFolder;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public final class CLibraryPathEntry extends ACPathEntry implements
|
||||
ICLibraryPathEntry {
|
||||
|
||||
public CLibraryPathEntry(String value, int flags) {
|
||||
super(value, flags);
|
||||
/**
|
||||
* Representation in the project model of library path settings entries.
|
||||
* As an example, those are supplied by a gcc compiler with option "-L".
|
||||
*/
|
||||
public final class CLibraryPathEntry extends ACPathEntry implements ICLibraryPathEntry {
|
||||
/**
|
||||
* This constructor is discouraged to be referenced by clients.
|
||||
*
|
||||
* Instead, use pooled entries with CDataUtil.createCLibraryPathEntry(name, flags).
|
||||
*
|
||||
* @param name - library 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 CLibraryPathEntry(String name, int flags) {
|
||||
super(name, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is discouraged to be used directly.
|
||||
*
|
||||
* Instead, use pooled entries with CDataUtil.createCLibraryPathEntry(location.toString(), flags)
|
||||
* or wrap it with CDataUtil.getPooledEntry(new CLibraryPathEntry(location, flags)).
|
||||
*
|
||||
* @param location - library 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 CLibraryPathEntry(IPath location, int flags) {
|
||||
super(location, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is discouraged to be used directly.
|
||||
*
|
||||
* Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CLibraryPathEntry(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 CLibraryPathEntry(IFolder rc, int flags) {
|
||||
super(rc, flags);
|
||||
}
|
||||
|
|
|
@ -419,6 +419,26 @@ public class CDataUtil {
|
|||
return (CMacroFileEntry) getPooledEntry(new CMacroFileEntry(name, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to create {@link CLibraryPathEntry}.
|
||||
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
|
||||
*
|
||||
* @since 5.4
|
||||
*/
|
||||
public static CLibraryPathEntry createCLibraryPathEntry(String name, int flags) {
|
||||
return (CLibraryPathEntry) getPooledEntry(new CLibraryPathEntry(name, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to create {@link CLibraryFileEntry}.
|
||||
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
|
||||
*
|
||||
* @since 5.4
|
||||
*/
|
||||
public static CLibraryFileEntry createCLibraryFileEntry(String name, int flags) {
|
||||
return (CLibraryFileEntry) getPooledEntry(new CLibraryFileEntry(name, flags));
|
||||
}
|
||||
|
||||
public static String[] getSourceExtensions(IProject project, CLanguageData data) {
|
||||
String[] exts = null;
|
||||
String[] typeIds = data.getSourceContentTypeIds();
|
||||
|
|
|
@ -12,9 +12,9 @@ package org.eclipse.cdt.ui.newui;
|
|||
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
||||
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.
|
||||
|
@ -29,7 +29,7 @@ public class ExpLibraryPathTab extends AbstractExportTab implements IPathEntrySt
|
|||
@Override
|
||||
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
|
||||
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
|
||||
return new CLibraryPathEntry(s2, flags);
|
||||
return CDataUtil.createCLibraryPathEntry(s2, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,9 +12,9 @@ package org.eclipse.cdt.ui.newui;
|
|||
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
||||
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.
|
||||
|
@ -29,7 +29,7 @@ public class ExpLibraryTab extends AbstractExportTab implements IPathEntryStoreL
|
|||
@Override
|
||||
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
|
||||
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
|
||||
return new CLibraryFileEntry(s2, flags);
|
||||
return CDataUtil.createCLibraryFileEntry(s2, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.eclipse.swt.widgets.TableColumn;
|
|||
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
||||
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 class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
|
|||
toAllLang = dlg.check3;
|
||||
int flags = 0;
|
||||
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
return new CLibraryPathEntry(dlg.text1, flags);
|
||||
return CDataUtil.createCLibraryPathEntry(dlg.text1, flags);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
|
|||
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
|
||||
int flags = 0;
|
||||
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
return new CLibraryPathEntry(dlg.text1, flags);
|
||||
return CDataUtil.createCLibraryPathEntry(dlg.text1, flags);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.swt.widgets.TableColumn;
|
|||
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
||||
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;
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
|
|||
toAllLang = dlg.check3;
|
||||
int flags = 0;
|
||||
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
return new CLibraryFileEntry(dlg.text1, flags);
|
||||
return CDataUtil.createCLibraryFileEntry(dlg.text1, flags);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
|
|||
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
|
||||
int flags = 0;
|
||||
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
return new CLibraryFileEntry(dlg.text1, flags);
|
||||
return CDataUtil.createCLibraryFileEntry(dlg.text1, flags);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue