diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
index 3d0ef7a3195..e4a4b9df7df 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
@@ -12,7 +12,6 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
public class CoreModel {
@@ -145,36 +144,20 @@ public class CoreModel {
return manager.hasCNature(project);
}
+ /**
+ * Return true if project has C++ nature.
+ */
public boolean hasCCNature(IProject project){
return manager.hasCCNature(project);
}
/**
- * Return the binaryParser of the Project.
+ * TODO: this is a temporary hack until, the CDescriptor manager is
+ * in place and could fire deltas of Parser change.
+ * @deprecated this function will be removed shortly.
*/
- public String getBinaryParserFormat(IProject project) {
- return manager.getBinaryParserFormat(project);
- }
-
- /**
- * Set the binaryParser of the Project.
- */
- public void setBinaryParserFormat(IProject project, String format, IProgressMonitor monitor) {
- manager.setBinaryParserFormat(project, format, monitor);
- }
-
- /**
- * Return the default BinaryParser format
- */
- public String getDefaultBinaryParserFormat() {
- return manager.getDefaultBinaryParserFormat();
- }
-
- /**
- * Set the default binaryParser.
- */
- public void setDefaultBinaryParserFormat(String format) {
- manager.setDefaultBinaryParserFormat(format);
+ public void resetBinaryParser(IProject project) {
+ manager.resetBinaryParser(project);
}
/**
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
index 918f292da11..00d035125f6 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
@@ -20,7 +20,6 @@ import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IBinary;
@@ -32,7 +31,6 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ICResource;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.internal.core.model.parser.ElfParser;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -47,19 +45,12 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.QualifiedName;
public class CModelManager implements IResourceChangeListener {
private Map fParsedResources = Collections.synchronizedMap(new HashMap());
-
- final static String BINARY_PARSER= "binaryparser";
-
- static QualifiedName binaryParserKey = new QualifiedName(CoreModel.CORE_MODEL_ID, BINARY_PARSER);
- private static HashMap fParsers = new HashMap();
- private static IBinaryParser defaultBinaryParser = new ElfParser();
- //private static IBinaryParser defaultBinaryParser = new PEParser();
+ //private static HashMap fParsers = new HashMap();
/**
* Used to convert IResourceDelta
s into IJavaElementDelta
s.
@@ -377,84 +368,126 @@ public class CModelManager implements IResourceChangeListener {
}
return null;
}
-
+
public IBinaryParser getBinaryParser(IProject project) {
- // It is in the property of the project of the cdtproject
- // For now the default is Elf.
- IBinaryParser parser = (IBinaryParser)fParsers.get(project);
- if (parser == null) {
- String format = getBinaryParserFormat(project);
- if (format == null || format.length() == 0) {
- format = getDefaultBinaryParserFormat();
- }
- if (format != null && format.length() > 0) {
- parser = CCorePlugin.getDefault().getBinaryParser(format);
- }
- if (parser == null) {
- parser = defaultBinaryParser;
- }
- fParsers.put(project, parser);
- }
- return parser;
- }
-
- public String getDefaultBinaryParserFormat() {
- String format = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(BINARY_PARSER);
- if (format == null || format.length() == 0) {
- return "ELF";
- }
- return format;
- }
-
- public String getBinaryParserFormat(IProject project) {
- // It can be in the property of the project or in the .cdtproject
- String format = null;
- // FIXME: Ask the .cdtproject.
try {
- if (project != null) {
- format = project.getPersistentProperty(binaryParserKey);
- }
+ return CCorePlugin.getDefault().getBinaryParser(project);
} catch (CoreException e) {
}
- return format;
+ return new NullBinaryParser();
}
- public void setDefaultBinaryParserFormat(String format) {
- CCorePlugin.getDefault().getPluginPreferences().setDefault(BINARY_PARSER, format);
- }
+// public IBinaryParser getBinaryParser(IProject project) {
+// // It is in the property of the project of the cdtproject
+// // For now the default is Elf.
+// IBinaryParser parser = (IBinaryParser)fParsers.get(project);
+// if (parser == null) {
+// String format = getBinaryParserFormat(project);
+// if (format == null || format.length() == 0) {
+// format = getDefaultBinaryParserFormat();
+// }
+// if (format != null && format.length() > 0) {
+// parser = CCorePlugin.getDefault().getBinaryParser(format);
+// }
+// if (parser == null) {
+// parser = defaultBinaryParser;
+// }
+// fParsers.put(project, parser);
+// }
+// return parser;
+// }
- public void setBinaryParserFormat(IProject project, String format, IProgressMonitor monitor) {
- try {
- if (project != null) {
- project.setPersistentProperty(binaryParserKey, format);
- fParsers.remove(project);
- IPath projPath = project.getFullPath();
- if (projPath != null) {
- Collection c = fParsedResources.values();
- ArrayList list = new ArrayList();
- synchronized (c) {
- Iterator values = c.iterator();
- while (values.hasNext()) {
- ICElement ce = (ICElement)values.next();
- if (!(ce instanceof ICRoot || ce instanceof ICProject)) {
- if (ce.getCProject().getProject().equals(project)) {
- list.add(ce);
- }
+// public String getDefaultBinaryParserFormat() {
+// String format = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(BINARY_PARSER);
+// if (format == null || format.length() == 0) {
+// return "ELF";
+// }
+// return format;
+// }
+
+// public String getBinaryParserFormat(IProject project) {
+// // It can be in the property of the project or in the .cdtproject
+// String format = null;
+// // FIXME: Ask the .cdtproject.
+// try {
+// if (project != null) {
+// format = project.getPersistentProperty(binaryParserKey);
+// }
+// } catch (CoreException e) {
+// }
+// return format;
+// }
+
+// public void setDefaultBinaryParserFormat(String format) {
+// CCorePlugin.getDefault().getPluginPreferences().setDefault(BINARY_PARSER, format);
+// }
+//
+// public void setBinaryParserFormat(IProject project, String format, IProgressMonitor monitor) {
+// try {
+// if (project != null) {
+// project.setPersistentProperty(binaryParserKey, format);
+// fParsers.remove(project);
+// IPath projPath = project.getFullPath();
+// if (projPath != null) {
+// Collection c = fParsedResources.values();
+// ArrayList list = new ArrayList();
+// synchronized (c) {
+// Iterator values = c.iterator();
+// while (values.hasNext()) {
+// ICElement ce = (ICElement)values.next();
+// if (!(ce instanceof ICRoot || ce instanceof ICProject)) {
+// if (ce.getCProject().getProject().equals(project)) {
+// list.add(ce);
+// }
+// }
+// }
+// }
+// for (int i = 0; i < list.size(); i++) {
+// ICElement ce = (ICElement)list.get(i);
+// releaseCElement(ce);
+// }
+// }
+// // Fired and ICElementDelta.PARSER_CHANGED
+// CElementDelta delta = new CElementDelta(getCRoot());
+// delta.binaryParserChanged(create(project));
+// registerCModelDelta(delta);
+// fire();
+// }
+// } catch (CoreException e) {
+// }
+// }
+
+ /**
+ * TODO: this is a temporary hack until, the CDescriptor manager is
+ * in place and could fire deltas of Parser change.
+ */
+ public void resetBinaryParser(IProject project) {
+ if (project != null) {
+ IPath projPath = project.getFullPath();
+ if (projPath != null) {
+ Collection c = fParsedResources.values();
+ ArrayList list = new ArrayList();
+ synchronized (c) {
+ Iterator values = c.iterator();
+ while (values.hasNext()) {
+ ICElement ce = (ICElement)values.next();
+ if (!(ce instanceof ICRoot || ce instanceof ICProject)) {
+ if (ce.getCProject().getProject().equals(project)) {
+ list.add(ce);
}
}
}
- for (int i = 0; i < list.size(); i++) {
- ICElement ce = (ICElement)list.get(i);
- releaseCElement(ce);
- }
}
- // Fired and ICElementDelta.PARSER_CHANGED
- CElementDelta delta = new CElementDelta(getCRoot());
- delta.binaryParserChanged(create(project));
- registerCModelDelta(delta);
- fire();
+ for (int i = 0; i < list.size(); i++) {
+ ICElement ce = (ICElement)list.get(i);
+ releaseCElement(ce);
+ }
}
- } catch (CoreException e) {
+ // Fired and ICElementDelta.PARSER_CHANGED
+ CElementDelta delta = new CElementDelta(getCRoot());
+ delta.binaryParserChanged(create(project));
+ registerCModelDelta(delta);
+ fire();
}
}
@@ -464,7 +497,6 @@ public class CModelManager implements IResourceChangeListener {
IBinaryFile bin = parser.getBinary(file.getLocation());
return (bin.getType() == IBinaryFile.SHARED);
} catch (IOException e) {
- //e.printStackTrace();
}
return false;
}
@@ -475,7 +507,6 @@ public class CModelManager implements IResourceChangeListener {
IBinaryFile bin = parser.getBinary(file.getLocation());
return (bin.getType() == IBinaryFile.OBJECT);
} catch (IOException e) {
- //e.printStackTrace();
}
return false;
}
@@ -500,7 +531,6 @@ public class CModelManager implements IResourceChangeListener {
|| bin.getType() == IBinaryFile.SHARED
|| bin.getType() == IBinaryFile.CORE);
} catch (IOException e) {
- //e.printStackTrace();
}
return false;
}
@@ -511,7 +541,6 @@ public class CModelManager implements IResourceChangeListener {
IBinaryFile bin = parser.getBinary(file.getLocation());
return (bin.getType() == IBinaryFile.ARCHIVE);
} catch (IOException e) {
- //e.printStackTrace();
}
return false;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java
new file mode 100644
index 00000000000..78786374519
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java
@@ -0,0 +1,35 @@
+package org.eclipse.cdt.internal.core.model;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author alain
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class NullBinaryParser implements IBinaryParser {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath)
+ */
+ public IBinaryFile getBinary(IPath path) throws IOException {
+ throw new IOException("not a binary file");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.IBinaryParser#getFormat()
+ */
+ public String getFormat() {
+ return "Null Format";
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
index 2adb4acaa2e..0d37205ce26 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
@@ -7,6 +7,7 @@ package org.eclipse.cdt.internal.core.model.parser;
import java.io.IOException;
+import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.utils.elf.AR;
import org.eclipse.cdt.utils.elf.Elf;
@@ -14,7 +15,7 @@ import org.eclipse.core.runtime.IPath;
/**
*/
-public class ElfParser implements IBinaryParser {
+public class ElfParser extends AbstractCExtension implements IBinaryParser {
/**
* @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath)
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
index 6cfe3a0e5ad..1d1e866b682 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
@@ -7,6 +7,7 @@ package org.eclipse.cdt.internal.core.model.parser;
import java.io.IOException;
+import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.utils.coff.PE;
import org.eclipse.cdt.utils.coff.PEArchive;
@@ -14,7 +15,7 @@ import org.eclipse.core.runtime.IPath;
/**
*/
-public class PEParser implements IBinaryParser {
+public class PEParser extends AbstractCExtension implements IBinaryParser {
/**
* @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IFile)
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index d39219a0386..c5334414478 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -77,19 +77,19 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
0)
+ parser = (IBinaryParser) cextensions[0].createExtension();
+ } catch (CoreException e) {
+ }
+ if (parser == null) {
+ String id = getPluginPreferences().getDefaultString(PREF_BINARY_PARSER);
+ if (id == null || id.length() == 0) {
+ id = DEFAULT_BINARY_PARSER_UNIQ_ID;
+ }
+ IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint(BINARY_PARSER_SIMPLE_ID);
+ IExtension extension = extensionPoint.getExtension(id);
+ if (extension != null) {
+ IConfigurationElement element[] = extension.getConfigurationElements();
+ for (int i = 0; i < element.length; i++) {
+ if (element[i].getName().equalsIgnoreCase("cextension")) {
+ parser = (IBinaryParser) element[i].createExecutableExtension("run");
+ break;
}
}
- }
- } catch (CoreException e) {
- }
- return null;
+ } else {
+ IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "No Binary Format", null);
+ throw new CoreException(s);
+ }
+ }
+ return parser;
}
public CoreModel getCoreModel() {
@@ -201,197 +208,236 @@ public class CCorePlugin extends Plugin {
public IndexModel getIndexModel() {
return IndexModel.getDefault();
- }
-
- public ICDescriptor getCProjectDescription(IProject project) throws CoreException {
+ }
+
+ public ICDescriptor getCProjectDescription(IProject project)
+ throws CoreException {
return fDescriptorManager.getDescriptor(project);
}
-
- public void mapCProjectOwner(IProject project, String id, boolean override) throws CoreException {
- if ( !override ) {
+
+ public void mapCProjectOwner(IProject project, String id, boolean override)
+ throws CoreException {
+ if (!override) {
fDescriptorManager.configure(project, id);
} else {
fDescriptorManager.convert(project, id);
}
}
-
- /**
- * Creates a C project resource given the project handle and description.
- *
- * @param description the project description to create a project resource for
- * @param projectHandle the project handle to create a project resource for
- * @param monitor the progress monitor to show visual progress with
- * @param projectID required for mapping the project to an owner
- *
- * @exception CoreException if the operation fails
- * @exception OperationCanceledException if the operation is canceled
- */
- public IProject createCProject(IProjectDescription description, IProject projectHandle,
- IProgressMonitor monitor, String projectID) throws CoreException, OperationCanceledException {
- try {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("Creating C Project", 3);//$NON-NLS-1$
- if (!projectHandle.exists()){
- projectHandle.create(description, monitor);
- }
- if (monitor.isCanceled()){
- throw new OperationCanceledException();
- }
-
- // Open first.
- projectHandle.open(monitor);
-
- // Add C Nature ... does not add duplicates
- CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
- mapCProjectOwner(projectHandle, projectID, false);
- } finally {
- //monitor.done();
- }
- return projectHandle;
- }
+ /**
+ * Creates a C project resource given the project handle and description.
+ *
+ * @param description the project description to create a project resource for
+ * @param projectHandle the project handle to create a project resource for
+ * @param monitor the progress monitor to show visual progress with
+ * @param projectID required for mapping the project to an owner
+ *
+ * @exception CoreException if the operation fails
+ * @exception OperationCanceledException if the operation is canceled
+ */
+ public IProject createCProject(
+ IProjectDescription description,
+ IProject projectHandle,
+ IProgressMonitor monitor,
+ String projectID)
+ throws CoreException, OperationCanceledException {
+ try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("Creating C Project", 3); //$NON-NLS-1$
+ if (!projectHandle.exists()) {
+ projectHandle.create(description, monitor);
+ }
+
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ // Open first.
+ projectHandle.open(monitor);
+
+ // Add C Nature ... does not add duplicates
+ CProjectNature.addCNature(
+ projectHandle,
+ new SubProgressMonitor(monitor, 1));
+ mapCProjectOwner(projectHandle, projectID, false);
+ } finally {
+ //monitor.done();
+ }
+ return projectHandle;
+ }
+
+ /**
+ * Method convertProjectFromCtoCC converts
+ * a C Project to a C++ Project
+ * The newProject MUST, not be null, already have a C Nature
+ * && must NOT already have a C++ Nature
+ *
+ * @param projectHandle
+ * @param monitor
+ * @throws CoreException
+ */
+
+ public void convertProjectFromCtoCC(
+ IProject projectHandle,
+ IProgressMonitor monitor)
+ throws CoreException {
+ if ((projectHandle != null)
+ && projectHandle.hasNature(CCProjectNature.C_NATURE_ID)
+ && !projectHandle.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ // Add C++ Nature ... does not add duplicates
+ CCProjectNature.addCCNature(projectHandle, monitor);
+ }
+ }
- /**
- * Method convertProjectFromCtoCC converts
- * a C Project to a C++ Project
- * The newProject MUST, not be null, already have a C Nature
- * && must NOT already have a C++ Nature
- *
- * @param projectHandle
- * @param monitor
- * @throws CoreException
- */
-
- public void convertProjectFromCtoCC(IProject projectHandle, IProgressMonitor monitor)
- throws CoreException{
- if ((projectHandle != null)
- && projectHandle.hasNature(CCProjectNature.C_NATURE_ID)
- && !projectHandle.hasNature(CCProjectNature.CC_NATURE_ID)) {
- // Add C++ Nature ... does not add duplicates
- CCProjectNature.addCCNature(projectHandle, monitor);
- }
- }
-
/**
* Method addDefaultCBuilder adds the default C make builder
* @param projectHandle
* @param monitor
- * @exception CoreException
+ * @exception CoreException
*/
- public void addDefaultCBuilder( IProject projectHandle, IProgressMonitor monitor)
- throws CoreException{
- // Set the Default C Builder.
- CProjectNature.addCBuildSpec(projectHandle, monitor);
- }
+ public void addDefaultCBuilder(
+ IProject projectHandle,
+ IProgressMonitor monitor)
+ throws CoreException {
+ // Set the Default C Builder.
+ CProjectNature.addCBuildSpec(projectHandle, monitor);
+ }
- /**
- * Method to convert a project to a C nature
- * & default make builder (Will always add a default builder)
- * All checks should have been done externally
- * (as in the Conversion Wizards).
- * This method blindly does the conversion.
- *
- * @param project
- * @param String targetNature
- * @param monitor
- * @param projectID
- * @exception CoreException
- */
-
- public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID)
- throws CoreException{
- this.convertProjectToC(projectHandle, monitor, projectID, true);
+ /**
+ * Method to convert a project to a C nature
+ * & default make builder (Will always add a default builder)
+ * All checks should have been done externally
+ * (as in the Conversion Wizards).
+ * This method blindly does the conversion.
+ *
+ * @param project
+ * @param String targetNature
+ * @param monitor
+ * @param projectID
+ * @exception CoreException
+ */
+
+ public void convertProjectToC(
+ IProject projectHandle,
+ IProgressMonitor monitor,
+ String projectID)
+ throws CoreException {
+ this.convertProjectToC(projectHandle, monitor, projectID, true);
+
+ }
+ /**
+ * Method to convert a project to a C nature
+ * & default make builder (if indicated)
+ * All checks should have been done externally
+ * (as in the Conversion Wizards).
+ * This method blindly does the conversion.
+ *
+ * @param project
+ * @param String targetNature
+ * @param monitor
+ * @param projectID
+ * @param addMakeBuilder
+ * @exception CoreException
+ */
+
+ public void convertProjectToC(
+ IProject projectHandle,
+ IProgressMonitor monitor,
+ String projectID,
+ boolean addMakeBuilder)
+ throws CoreException {
+ if ((projectHandle == null)
+ || (monitor == null)
+ || (projectID == null)) {
+ return;
+ }
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProjectDescription description =
+ workspace.newProjectDescription(projectHandle.getName());
+ description.setLocation(projectHandle.getFullPath());
+ createCProject(description, projectHandle, monitor, projectID);
+ if (addMakeBuilder) {
+ addDefaultCBuilder(projectHandle, monitor);
+ }
+ }
+ /**
+ * Method to convert a project to a C++ nature
+ * & default make builder(if indicated), if it does not have one already
+ *
+ * @param project
+ * @param String targetNature
+ * @param monitor
+ * @param projectID
+ * @param addMakeBuilder
+ * @exception CoreException
+ */
+
+ public void convertProjectToCC(
+ IProject projectHandle,
+ IProgressMonitor monitor,
+ String projectID,
+ boolean addMakeBuilder)
+ throws CoreException {
+ if ((projectHandle == null)
+ || (monitor == null)
+ || (projectID == null)) {
+ return;
+ }
+ createCProject(
+ projectHandle.getDescription(),
+ projectHandle,
+ monitor,
+ projectID);
+ // now add C++ nature
+ convertProjectFromCtoCC(projectHandle, monitor);
+ if (addMakeBuilder) {
+ addDefaultCBuilder(projectHandle, monitor);
+ }
+ }
+ /**
+ * Method to convert a project to a C++ nature
+ * & default make builder,
+ * Note: Always adds the default Make builder
+ *
+ * @param project
+ * @param String targetNature
+ * @param monitor
+ * @param projectID
+ * @exception CoreException
+ */
+
+ public void convertProjectToCC(
+ IProject projectHandle,
+ IProgressMonitor monitor,
+ String projectID)
+ throws CoreException {
+ this.convertProjectToCC(projectHandle, monitor, projectID, true);
+ }
+
+ // Extract the builder from the .cdtproject.
+ // public ICBuilder[] getBuilders(IProject project) throws CoreException {
+ // ICExtension extensions[] = fDescriptorManager.createExtensions(BUILDER_MODEL_ID, project);
+ // ICBuilder builders[] = new ICBuilder[extensions.length];
+ // System.arraycopy(extensions, 0, builders, 0, extensions.length);
+ // return builders;
+ // }
- }
- /**
- * Method to convert a project to a C nature
- * & default make builder (if indicated)
- * All checks should have been done externally
- * (as in the Conversion Wizards).
- * This method blindly does the conversion.
- *
- * @param project
- * @param String targetNature
- * @param monitor
- * @param projectID
- * @param addMakeBuilder
- * @exception CoreException
- */
-
- public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID, boolean addMakeBuilder)
- throws CoreException{
- if ((projectHandle == null) || (monitor == null) || (projectID == null)){
- return;
- }
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProjectDescription description = workspace.newProjectDescription(projectHandle.getName());
- description.setLocation(projectHandle.getFullPath());
- createCProject(description, projectHandle, monitor, projectID);
- if (addMakeBuilder) {
- addDefaultCBuilder(projectHandle, monitor);
- }
- }
- /**
- * Method to convert a project to a C++ nature
- * & default make builder(if indicated), if it does not have one already
- *
- * @param project
- * @param String targetNature
- * @param monitor
- * @param projectID
- * @param addMakeBuilder
- * @exception CoreException
- */
-
- public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID, boolean addMakeBuilder)
- throws CoreException{
- if ((projectHandle == null) || (monitor == null) || (projectID == null)){
- return;
- }
- createCProject(projectHandle.getDescription(), projectHandle, monitor, projectID);
- // now add C++ nature
- convertProjectFromCtoCC(projectHandle, monitor);
- if (addMakeBuilder){
- addDefaultCBuilder(projectHandle, monitor);
- }
- }
- /**
- * Method to convert a project to a C++ nature
- * & default make builder,
- * Note: Always adds the default Make builder
- *
- * @param project
- * @param String targetNature
- * @param monitor
- * @param projectID
- * @exception CoreException
- */
-
- public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID)
- throws CoreException{
- this.convertProjectToCC(projectHandle, monitor, projectID, true);
- }
-
-// Extract the builder from the .cdtproject.
-// public ICBuilder[] getBuilders(IProject project) throws CoreException {
-// ICExtension extensions[] = fDescriptorManager.createExtensions(BUILDER_MODEL_ID, project);
-// ICBuilder builders[] = new ICBuilder[extensions.length];
-// System.arraycopy(extensions, 0, builders, 0, extensions.length);
-// return builders;
-// }
-
public IProcessList getProcessList() {
- IExtensionPoint extension = getDescriptor().getExtensionPoint("ProcessList");
+ IExtensionPoint extension =
+ getDescriptor().getExtensionPoint("ProcessList");
if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- IConfigurationElement [] configElements = extensions[0].getConfigurationElements();
- if ( configElements.length != 0 ) {
+ IExtension[] extensions = extension.getExtensions();
+ IConfigurationElement[] configElements =
+ extensions[0].getConfigurationElements();
+ if (configElements.length != 0) {
try {
- return (IProcessList) configElements[0].createExecutableExtension("class");
- }
- catch (CoreException e) {
+ return (
+ IProcessList) configElements[0]
+ .createExecutableExtension(
+ "class");
+ } catch (CoreException e) {
}
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParserConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
deleted file mode 100644
index 638887e0236..00000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.eclipse.cdt.core;
-
-
-
-/**
- */
-public interface IBinaryParserConfiguration {
-
- String getFormat();
- String getName();
- IBinaryParser getParser();
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
deleted file mode 100644
index b8eedc3a505..00000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.eclipse.cdt.internal.core;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IBinaryParser;
-import org.eclipse.cdt.core.IBinaryParserConfiguration;
-
-/**
- */
-public class BinaryParserConfiguration implements IBinaryParserConfiguration {
-
- String format;
- String name;
-
- public BinaryParserConfiguration(String format, String name) {
- this.format = format;
- this.name = name;
- }
-
- /**
- * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getFormat()
- */
- public String getFormat() {
- return format;
- }
-
- /**
- * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getName()
- */
- public String getName() {
- return name;
- }
-
- /**
- * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getParser()
- */
- public IBinaryParser getParser() {
- return CCorePlugin.getDefault().getBinaryParser(format);
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
index 0f92d9a639c..d151ea128a7 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
@@ -46,8 +46,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class CDescriptor implements ICDescriptor {
- /* constants */
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
private COwner fOwner;
private IProject fProject;
private HashMap extMap = new HashMap(4);
@@ -177,12 +175,15 @@ public class CDescriptor implements ICDescriptor {
}
public ICExtensionReference[] get(String extensionID) {
- return (CExtensionReference[]) extMap.get(extensionID);
+ CExtensionReference[] refs = (CExtensionReference[]) extMap.get(extensionID);
+ if (refs == null)
+ return new ICExtensionReference[0];
+ return refs;
}
public ICExtensionReference[] get(String extensionID, boolean update) {
ICExtensionReference[] ext = get(extensionID);
- if ((ext == null || ext.length == 0) && update) {
+ if (ext.length == 0 && update) {
try {
fOwner.update(fProject, this, extensionID);
saveInfo();
@@ -204,8 +205,8 @@ public class CDescriptor implements ICDescriptor {
extensions = newExtensions;
extMap.put(extensionPoint, extensions);
}
- setDirty();
extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extensionID);
+ setDirty();
return extensions[extensions.length - 1];
}
@@ -230,7 +231,7 @@ public class CDescriptor implements ICDescriptor {
public void remove(String extensionPoint) throws CoreException {
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
if (extensions != null) {
- extMap.put(extensionPoint, null);
+ extMap.remove(extensionPoint);
setDirty();
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
index 18ef07bfe9a..1febab5a661 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
@@ -88,6 +88,7 @@ public class CDescriptorManager implements IResourceChangeListener {
cproject = (CDescriptor)fDescriptorMap.get(project) ;
if ( cproject == null ) {
cproject = new CDescriptor(project);
+ cproject.setAutoSave(true);
fDescriptorMap.put(project, cproject);
}
return cproject;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
index 97b407f8c7d..5b9a4613a92 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
@@ -6,29 +6,31 @@ package org.eclipse.cdt.ui.wizards;
*/
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IBinaryParserConfiguration;
-import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea;
import org.eclipse.cdt.utils.ui.swt.IValidation;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
-
public class BinaryParserBlock implements IWizardTab {
- private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
-
+ //private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
+ //private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+
private static String[][] radios;
private IProject project;
protected RadioButtonsArea radioButtons;
- private String defaultFormat;
-// protected Button defButton;
+ private String id;
+ // protected Button defButton;
IValidation page;
@@ -39,16 +41,28 @@ public class BinaryParserBlock implements IWizardTab {
public BinaryParserBlock(IValidation valid, IProject p) {
page = valid;
project = p;
- IBinaryParserConfiguration[] configs = CCorePlugin.getDefault().getBinaryParserConfigurations();
- radios = new String[configs.length][2];
- for (int i = 0; i < configs.length; i++) {
- radios[i] = new String[] {configs[i].getName(), configs[i].getFormat()};
+ IExtensionPoint point = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+ if (point != null) {
+ IExtension[] exts = point.getExtensions();
+ radios = new String[exts.length][2];
+ for (int i = 0; i < exts.length; i++) {
+ radios[i] = new String[] { exts[i].getLabel(), exts[i].getUniqueIdentifier()};
+ }
}
- CoreModel model = CCorePlugin.getDefault().getCoreModel();
- if (project == null) {
- defaultFormat = model.getDefaultBinaryParserFormat();
- } else {
- defaultFormat = model.getBinaryParserFormat(project);
+ try {
+ ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(p);
+ ICExtensionReference[] ref = desc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ if (ref.length > 0)
+ id = ref[0].getID();
+
+ } catch (CoreException e) {
+ //e.printStackTrace();
+ }
+ if (id == null) {
+ id = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(CCorePlugin.PREF_BINARY_PARSER);
+ if (id == null || id.length() == 0) {
+ id = CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID;
+ }
}
}
@@ -66,8 +80,8 @@ public class BinaryParserBlock implements IWizardTab {
radioButtons = new RadioButtonsArea(composite, "Parsers", 1, radios);
radioButtons.setEnabled(true);
- if (defaultFormat != null) {
- radioButtons.setSelectValue(defaultFormat);
+ if (id != null) {
+ radioButtons.setSelectValue(id);
}
return composite;
}
@@ -75,7 +89,7 @@ public class BinaryParserBlock implements IWizardTab {
public boolean isValid() {
return true;
}
-
+
public void setVisible(boolean visible) {
}
@@ -84,13 +98,18 @@ public class BinaryParserBlock implements IWizardTab {
monitor = new NullProgressMonitor();
}
monitor.beginTask("Parsers", 1);
- CoreModel model = CCorePlugin.getDefault().getCoreModel();
- String format = radioButtons.getSelectedValue();
- if (format != null) {
- if (defaultFormat == null || !format.equals(defaultFormat)) {
- model.setBinaryParserFormat(project, format, monitor);
- defaultFormat = format;
+ try {
+ ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project);
+ String identity = radioButtons.getSelectedValue();
+ if (identity != null) {
+ if (id == null || !identity.equals(id)) {
+ desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, identity);
+ CCorePlugin.getDefault().getCoreModel().resetBinaryParser(project);
+ id = identity;
+ }
}
+ } catch (CoreException e) {
}
}