1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 00:05:53 +02:00

Bug 301229 - Eliminate internal use of ICExtensionReference

This commit is contained in:
Anton Leherbauer 2010-02-16 07:46:12 +00:00
parent 9893d467ce
commit 0582fc2a23
13 changed files with 217 additions and 77 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,9 +10,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
/* /*
* BinaryParserConfig * BinaryParserConfig
@ -20,7 +23,7 @@ import org.eclipse.core.runtime.CoreException;
public class BinaryParserConfig { public class BinaryParserConfig {
private IBinaryParser parser; private IBinaryParser parser;
private final String id; private final String id;
private final ICExtensionReference ref; private final ICConfigExtensionReference ref;
public BinaryParserConfig(IBinaryParser parser, String id) { public BinaryParserConfig(IBinaryParser parser, String id) {
this.parser = parser; this.parser = parser;
@ -28,7 +31,7 @@ public class BinaryParserConfig {
this.ref = null; this.ref = null;
} }
public BinaryParserConfig(ICExtensionReference ref) { public BinaryParserConfig(ICConfigExtensionReference ref) {
this.ref = ref; this.ref = ref;
this.id = ref.getID(); this.id = ref.getID();
} }
@ -39,7 +42,12 @@ public class BinaryParserConfig {
public IBinaryParser getBinaryParser() throws CoreException { public IBinaryParser getBinaryParser() throws CoreException {
if (parser == null) { if (parser == null) {
parser = (IBinaryParser)ref.createExtension(); AbstractCExtension cExtension = null;
IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
cExtension.setExtensionReference(ref);
cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
parser = (IBinaryParser) cExtension;
} }
return parser; return parser;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -30,12 +30,8 @@ import java.util.Map;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CDescriptorEvent;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICDescriptorListener;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
@ -54,9 +50,18 @@ import org.eclipse.cdt.core.model.IProblemRequestor;
import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
import org.eclipse.cdt.core.settings.model.ICSettingObject;
import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.LocalProjectScope; import org.eclipse.cdt.internal.core.LocalProjectScope;
import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.IFileStore;
@ -82,7 +87,7 @@ import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener; import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener;
public class CModelManager implements IResourceChangeListener, ICDescriptorListener, IContentTypeChangeListener { public class CModelManager implements IResourceChangeListener, IContentTypeChangeListener, ICProjectDescriptionListener {
public static boolean VERBOSE = false; public static boolean VERBOSE = false;
@ -149,12 +154,12 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
/** /**
* The list of started BinaryRunners on projects. * The list of started BinaryRunners on projects.
*/ */
private HashMap<IProject, BinaryRunner> binaryRunners = new HashMap<IProject, BinaryRunner>(); private final Map<IProject, BinaryRunner> binaryRunners = new HashMap<IProject, BinaryRunner>();
/** /**
* Map of the binary parser for each project. * Map of the binary parser for each project.
*/ */
private HashMap<IProject, BinaryParserConfig[]> binaryParsersMap = new HashMap<IProject, BinaryParserConfig[]>(); private final Map<IProject, BinaryParserConfig[]> binaryParsersMap = Collections.synchronizedMap(new HashMap<IProject, BinaryParserConfig[]>());
/** /**
* The lis of the SourceMappers on projects. * The lis of the SourceMappers on projects.
@ -184,7 +189,12 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
// Register the Core Model on the Descriptor // Register the Core Model on the Descriptor
// Manager, it needs to know about changes. // Manager, it needs to know about changes.
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(factory); // CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(factory);
// Register as project description listener
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(factory,
CProjectDescriptionEvent.APPLIED);
// Register the Core Model on the ContentTypeManager // Register the Core Model on the ContentTypeManager
// it needs to know about changes. // it needs to know about changes.
Platform.getContentTypeManager().addContentTypeChangeListener(factory); Platform.getContentTypeManager().addContentTypeChangeListener(factory);
@ -588,14 +598,15 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
public BinaryParserConfig[] getBinaryParser(IProject project) { public BinaryParserConfig[] getBinaryParser(IProject project) {
BinaryParserConfig[] parsers = binaryParsersMap.get(project); BinaryParserConfig[] parsers = binaryParsersMap.get(project);
if (parsers == null) { if (parsers == null) {
try { ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project, false);
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false); if (desc != null) {
if (cdesc != null) { ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration();
ICExtensionReference[] cextensions = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID, true); if (cfgDesc != null) {
if (cextensions.length > 0) { ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(cextensions.length); if (refs.length > 0) {
for (ICExtensionReference cextension : cextensions) { ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(refs.length);
BinaryParserConfig config = new BinaryParserConfig(cextension); for (ICConfigExtensionReference ref : refs) {
BinaryParserConfig config = new BinaryParserConfig(ref);
list.add(config); list.add(config);
} }
parsers = new BinaryParserConfig[list.size()]; parsers = new BinaryParserConfig[list.size()];
@ -605,7 +616,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
parsers = new BinaryParserConfig[0]; parsers = new BinaryParserConfig[0];
} }
} }
} catch (CoreException e) {
} }
if (parsers == null) { if (parsers == null) {
try { try {
@ -774,7 +784,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
} }
public void removeBinaryRunner(IProject project) { public void removeBinaryRunner(IProject project) {
BinaryRunner runner = binaryRunners.remove(project); BinaryRunner runner;
synchronized (binaryRunners) {
runner = binaryRunners.remove(project);
}
if (runner != null) { if (runner != null) {
runner.stop(); runner.stop();
} }
@ -879,19 +892,33 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
} }
} }
/* (non-Javadoc) public void handleEvent(CProjectDescriptionEvent event) {
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent) switch(event.getEventType()) {
*/ case CProjectDescriptionEvent.APPLIED:
public void descriptorChanged(CDescriptorEvent event) { CProjectDescription newDes = (CProjectDescription)event.getNewCProjectDescription();
int flags = event.getFlags(); CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription();
if ( (flags & CDescriptorEvent.EXTENSION_CHANGED) != 0) { if(oldDes != null && newDes != null) {
ICDescriptor cdesc = event.getDescriptor(); ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration();
if (cdesc != null) { ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration();
IProject project = cdesc.getProject(); int flags = 0;
if(oldCfg != null && newCfg != null){
if(newCfg.getId().equals(oldCfg.getId())){
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
if(cfgDelta != null){
flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
}
} else {
flags = CProjectDescriptionManager.getInstance().calculateDescriptorFlags(newCfg, oldCfg);
}
}
if ((flags & ICDescriptionDelta.EXT_REF) != 0) {
// update binary parsers
IProject project = newDes.getProject();
try { try {
ICExtensionReference[] newExts = CCorePlugin.getDefault().getBinaryParserExtensions(project); ICConfigExtensionReference[] newExts = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
BinaryParserConfig[] currentConfigs = getBinaryParser(project); BinaryParserConfig[] currentConfigs = binaryParsersMap.get(project);
// anything added/removed // anything added/removed
if (currentConfigs != null) {
if (newExts.length != currentConfigs.length) { if (newExts.length != currentConfigs.length) {
resetBinaryParser(project); resetBinaryParser(project);
} else { // may reorder } else { // may reorder
@ -902,11 +929,26 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
} }
} }
} }
}
} catch (CoreException e) { } catch (CoreException e) {
resetBinaryParser(project); resetBinaryParser(project);
} }
} }
} }
break;
}
}
private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){
if(delta == null)
return null;
ICDescriptionDelta children[] = delta.getChildren();
for(int i = 0; i < children.length; i++){
ICSettingObject s = children[i].getNewSetting();
if(s != null && id.equals(s.getId()))
return children[i];
}
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1234,14 +1276,18 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
*/ */
public void shutdown() { public void shutdown() {
// Remove ourself from the DescriptorManager. // Remove ourself from the DescriptorManager.
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(factory); CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
// CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(factory);
// Remove ourself from the ContentTypeManager // Remove ourself from the ContentTypeManager
Platform.getContentTypeManager().removeContentTypeChangeListener(factory); Platform.getContentTypeManager().removeContentTypeChangeListener(factory);
// Do any shutdown of services. // Do any shutdown of services.
ResourcesPlugin.getWorkspace().removeResourceChangeListener(factory); ResourcesPlugin.getWorkspace().removeResourceChangeListener(factory);
BinaryRunner[] runners = binaryRunners.values().toArray(new BinaryRunner[0]); BinaryRunner[] runners;
synchronized (binaryRunners) {
runners = binaryRunners.values().toArray(new BinaryRunner[0]);
}
for (BinaryRunner runner : runners) { for (BinaryRunner runner : runners) {
runner.stop(); runner.stop();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2008 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -412,4 +413,8 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
public ICExtensionReference getExtensionReference() { public ICExtensionReference getExtensionReference() {
return null; return null;
} }
public ICConfigExtensionReference getConfigExtensionReference() {
return null;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others. * Copyright (c) 2007, 2010 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy; import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy;
import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore; import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore;
@ -90,6 +91,10 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
return null; return null;
} }
public ICConfigExtensionReference getConfigExtensionReference() {
return null;
}
public IPathEntry[] getRawPathEntries() throws CoreException { public IPathEntry[] getRawPathEntries() throws CoreException {
providerRequested(); providerRequested();
return fStore.getRawPathEntries(); return fStore.getRawPathEntries();

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICExternalSetting; import org.eclipse.cdt.core.settings.model.ICExternalSetting;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@ -100,6 +101,10 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
return null; return null;
} }
public ICConfigExtensionReference getConfigExtensionReference() {
return null;
}
public IPathEntry[] getRawPathEntries() throws CoreException { public IPathEntry[] getRawPathEntries() throws CoreException {
ICConfigurationDescription cfg = getIndexCfg(fProject); ICConfigurationDescription cfg = getIndexCfg(fProject);
List<IPathEntry>[] es = getEntries(fProject, cfg); List<IPathEntry>[] es = getEntries(fProject, cfg);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2005 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,15 +10,18 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core; package org.eclipse.cdt.core;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
public abstract class AbstractCExtension extends PlatformObject implements ICExtension { public abstract class AbstractCExtension extends PlatformObject implements ICExtension {
private IProject fProject; private IProject fProject;
private ICExtensionReference extensionRef; private ICExtensionReference extensionRef;
private ICConfigExtensionReference fCfgExtensionRef;
/** /**
* Returns the project for which this extrension is defined. * Returns the project for which this extension is defined.
* *
* @return the project * @return the project
*/ */
@ -26,10 +29,39 @@ public abstract class AbstractCExtension extends PlatformObject implements ICExt
return fProject; return fProject;
} }
/**
* <strong>May return <code>null</code>!</strong>
* @deprecated Use {@link #getConfigExtensionReference()} instead.
*/
@Deprecated
public final ICExtensionReference getExtensionReference() { public final ICExtensionReference getExtensionReference() {
if (extensionRef == null) {
// try to create one for the sake of backwards compatibility
try {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(getProject(), false);
if (cdesc != null) {
ICExtensionReference[] cextensions = cdesc.get(fCfgExtensionRef.getExtensionPoint(), false);
for (ICExtensionReference ref : cextensions) {
if (ref.getID().equals(fCfgExtensionRef.getID())) {
extensionRef = ref;
break;
}
}
}
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
return extensionRef; return extensionRef;
} }
/**
* Returns the extension reference this extension was created from.
* @since 5.2
*/
public final ICConfigExtensionReference getConfigExtensionReference() {
return fCfgExtensionRef;
}
// internal stuff // internal stuff
/** /**
@ -45,4 +77,11 @@ public abstract class AbstractCExtension extends PlatformObject implements ICExt
public void setExtensionReference(ICExtensionReference extReference) { public void setExtensionReference(ICExtensionReference extReference) {
extensionRef = extReference; extensionRef = extReference;
} }
/**
* @noreference This method is not intended to be referenced by clients.
*/
public void setExtensionReference(ICConfigExtensionReference extReference) {
fCfgExtensionRef = extReference;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others. * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
@ -527,6 +528,10 @@ public class CCorePlugin extends Plugin {
return getConsole(consoleID); return getConsole(consoleID);
} }
/**
* @deprecated Use {@link #getDefaultBinaryParserExtensions(IProject)} instead.
*/
@Deprecated
public ICExtensionReference[] getBinaryParserExtensions(IProject project) throws CoreException { public ICExtensionReference[] getBinaryParserExtensions(IProject project) throws CoreException {
ICExtensionReference ext[] = new ICExtensionReference[0]; ICExtensionReference ext[] = new ICExtensionReference[0];
if (project != null) { if (project != null) {
@ -544,6 +549,24 @@ public class CCorePlugin extends Plugin {
return ext; return ext;
} }
/**
* Returns the binary parser extensions for the default settings configuration.
* @since 5.2
*/
public ICConfigExtensionReference[] getDefaultBinaryParserExtensions(IProject project) throws CoreException {
ICConfigExtensionReference ext[] = new ICConfigExtensionReference[0];
if (project != null) {
ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project, false);
if (desc != null) {
ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration();
if (cfgDesc != null) {
ext = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
}
}
}
return ext;
}
/** /**
* @deprecated - use getBinaryParserExtensions(IProject project) * @deprecated - use getBinaryParserExtensions(IProject project)
*/ */

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2005 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core; package org.eclipse.cdt.core;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
/** /**
@ -19,5 +20,13 @@ import org.eclipse.core.resources.IProject;
*/ */
public interface ICExtension { public interface ICExtension {
public IProject getProject(); public IProject getProject();
/**
* @deprecated Use {@link #getConfigExtensionReference()} instead.
*/
@Deprecated
public ICExtensionReference getExtensionReference(); public ICExtensionReference getExtensionReference();
/**
* @since 5.2
*/
public ICConfigExtensionReference getConfigExtensionReference();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 Intel Corporation and others. * Copyright (c) 2007, 2010 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -160,7 +160,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
AbstractCExtension cExtension = null; AbstractCExtension cExtension = null;
IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false); IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false);
cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$ cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
cExtension.setExtensionReference(this); cExtension.setExtensionReference(fCfgExtRef);
cExtension.setProject(getProject()); cExtension.setProject(getProject());
return cExtension; return cExtension;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems and others. * Copyright (c) 2004, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,7 @@ package org.eclipse.cdt.utils;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.ICExtension; import org.eclipse.cdt.core.ICExtension;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -45,7 +45,7 @@ public class DefaultCygwinToolFactory extends DefaultGnuToolFactory implements I
} }
protected IPath getCygPathPath() { protected IPath getCygPathPath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("cygpath"); //$NON-NLS-1$ String value = ref.getExtensionData("cygpath"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "cygpath"; //$NON-NLS-1$ value = "cygpath"; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems and others. * Copyright (c) 2004, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,7 @@ package org.eclipse.cdt.utils;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.ICExtension; import org.eclipse.cdt.core.ICExtension;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -91,7 +91,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected IPath getAddr2linePath() { protected IPath getAddr2linePath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("addr2line"); //$NON-NLS-1$ String value = ref.getExtensionData("addr2line"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "addr2line"; //$NON-NLS-1$ value = "addr2line"; //$NON-NLS-1$
@ -100,7 +100,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected IPath getObjdumpPath() { protected IPath getObjdumpPath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("objdump"); //$NON-NLS-1$ String value = ref.getExtensionData("objdump"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "objdump"; //$NON-NLS-1$ value = "objdump"; //$NON-NLS-1$
@ -109,7 +109,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected String getObjdumpArgs() { protected String getObjdumpArgs() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("objdumpArgs"); //$NON-NLS-1$ String value = ref.getExtensionData("objdumpArgs"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = ""; //$NON-NLS-1$ value = ""; //$NON-NLS-1$
@ -118,7 +118,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected IPath getCPPFiltPath() { protected IPath getCPPFiltPath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$ String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "c++filt"; //$NON-NLS-1$ value = "c++filt"; //$NON-NLS-1$
@ -127,7 +127,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected IPath getStripPath() { protected IPath getStripPath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("strip"); //$NON-NLS-1$ String value = ref.getExtensionData("strip"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "strip"; //$NON-NLS-1$ value = "strip"; //$NON-NLS-1$
@ -136,7 +136,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected IPath getNMPath() { protected IPath getNMPath() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("nm"); //$NON-NLS-1$ String value = ref.getExtensionData("nm"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "nm"; //$NON-NLS-1$ value = "nm"; //$NON-NLS-1$
@ -145,7 +145,7 @@ public class DefaultGnuToolFactory implements IGnuToolFactory {
} }
protected String getNMArgs() { protected String getNMArgs() {
ICExtensionReference ref = fExtension.getExtensionReference(); ICConfigExtensionReference ref = fExtension.getConfigExtensionReference();
String value = ref.getExtensionData("nmArgs"); //$NON-NLS-1$ String value = ref.getExtensionData("nmArgs"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = ""; //$NON-NLS-1$ value = ""; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2007 QNX Software Systems and others. * Copyright (c) 2002, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -15,7 +15,7 @@ import java.io.IOException;
import org.eclipse.cdt.core.AbstractCExtension; import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.CPPFilt;
import org.eclipse.cdt.utils.macho.AR; import org.eclipse.cdt.utils.macho.AR;
import org.eclipse.cdt.utils.macho.MachO; import org.eclipse.cdt.utils.macho.MachO;
@ -121,7 +121,7 @@ public class MachOParser extends AbstractCExtension implements IBinaryParser {
} }
protected IPath getCPPFiltPath() { protected IPath getCPPFiltPath() {
ICExtensionReference ref = getExtensionReference(); ICConfigExtensionReference ref = getConfigExtensionReference();
String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$ String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "c++filt"; //$NON-NLS-1$ value = "c++filt"; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2009 QNX Software Systems and others. * Copyright (c) 2002, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -15,7 +15,7 @@ import java.io.IOException;
import org.eclipse.cdt.core.AbstractCExtension; import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.CPPFilt;
import org.eclipse.cdt.utils.macho.AR; import org.eclipse.cdt.utils.macho.AR;
import org.eclipse.cdt.utils.macho.MachO64; import org.eclipse.cdt.utils.macho.MachO64;
@ -120,7 +120,7 @@ public class MachOParser64 extends AbstractCExtension implements IBinaryParser {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected IPath getCPPFiltPath() { protected IPath getCPPFiltPath() {
ICExtensionReference ref = getExtensionReference(); ICConfigExtensionReference ref = getConfigExtensionReference();
String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$ String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
value = "c++filt"; //$NON-NLS-1$ value = "c++filt"; //$NON-NLS-1$