Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] implementing binaryparser proposal

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.70
diff -u -r1.70 ChangeLog
--- ChangeLog	26 Feb 2003 21:38:55 -0000	1.70
+++ ChangeLog	28 Feb 2003 21:23:01 -0000
@@ -1,6 +1,49 @@
 2003-02-26 Alain Magloire
 
-	A new proposal was make, see cdt-core-home/docs/binarparser.html
+	The second part to finish the cdt-core-home/docs/binaryparser.html
+	proposal.  The plugin.xml changed to reflect this, new format.
+
+	<extension id="ELF" name="Elf Parser" point="org.eclipse.cdt.core.BinaryParser">
+	 <cextension>
+	   <run class="org.eclipse.cdt.internal.core.model.parser.ElfParser"/>
+	 </cextension>
+	</extension>
+
+	<extension id="PE" name="PE Windows Parser" point="org.eclipse.cdt.core.BinaryParser">
+	 <cextension>
+	  <run class="org.eclipse.cdt.internal.core.model.parser.PEParser"> </run>
+	 </cextension>
+	</extension>
+
+	The binary parser type is now save in the ".cdtproject".
+
+	* src/org/eclipse/cdt/core/IBinaryParserConfiguration.java:
+	* src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java:
+	Removed.
+
+	* src/org/eclipse/cdt/internal/core/CDescriptorManager.java
+	(getDescriptor): Call autosave().
+	* src/org/eclipse/cdt/internal/core/CDescriptor.java
+	(create): Bug fix
+	(get): Bug fix
+	(remove): Bug fix
+
+	* model/org/eclipse/cdt/internal/core/model/parser/ElParser.java:
+	* model/org/eclipse/cdt/internal/core/model/parser/PEParser.java:
+	Extends AbstractCDescriptor.
+	* model/org/eclipse/cdt/core/internal/core/model/NullBinaryParser.java:
+	New file.
+	* model/org/eclipse/cdt/core/internal/core/model/CModelManager.java:
+	* model/org/eclipse/cdt/core/model/CoreModel.java
+	(resetBinaryParser): New method.
+	(getBinaryParserFormat): removed.
+	(setBinaryParserFormat): removed.
+	(setDefaultBinaryParserFormat): removed.
+	(getDefaultBinaryParserFormat): removed.
+
+2003-02-26 Alain Magloire
+
+	A new proposal was make, see cdt-core-home/docs/binaryparser.html
 	it changed the the signature:
 	public interface IBinaryParser {
 		IBinary getBinary(IPath path);
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/plugin.xml,v
retrieving revision 1.18
diff -u -r1.18 plugin.xml
--- plugin.xml	17 Feb 2003 19:10:36 -0000	1.18
+++ plugin.xml	28 Feb 2003 21:23:01 -0000
@@ -77,19 +77,19 @@
       </type>
    </extension>
 
-   <extension
-         point="org.eclipse.cdt.core.BinaryParser">
-      <parser
-            name="Elf Parser"
-            class="org.eclipse.cdt.internal.core.model.parser.ElfParser"
-            format="ELF">
-      </parser>
-      <parser
-            name="PE Windows Parser"
-            class="org.eclipse.cdt.internal.core.model.parser.PEParser"
-            format="PE">
-      </parser>
-   </extension>
+   <!-- Define the list of the Binary Parser provided by the CDT -->
+   <extension id="ELF" name="Elf Parser" point="org.eclipse.cdt.core.BinaryParser">
+     <cextension>
+       <run class="org.eclipse.cdt.internal.core.model.parser.ElfParser"/>
+     </cextension>
+  </extension>
+
+  <extension id="PE" name="PE Windows Parser" point="org.eclipse.cdt.core.BinaryParser">
+    <cextension>
+      <run class="org.eclipse.cdt.internal.core.model.parser.PEParser"> </run>
+    </cextension>
+  </extension>
+
    <extension
          id="cbuilder"
          name="C Builder"
Index: model/org/eclipse/cdt/core/model/CoreModel.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java,v
retrieving revision 1.8
diff -u -r1.8 CoreModel.java
--- model/org/eclipse/cdt/core/model/CoreModel.java	29 Jan 2003 14:19:26 -0000	1.8
+++ model/org/eclipse/cdt/core/model/CoreModel.java	28 Feb 2003 21:23:01 -0000
@@ -12,7 +12,6 @@
 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 @@
 		return manager.hasCNature(project);
 	}
 
-	public boolean hasCCNature(IProject project){
-		return manager.hasCCNature(project);
-	}
-
-	/**
-	 * Return the binaryParser of the Project.
-	 */
-	public String getBinaryParserFormat(IProject project) {
-		return manager.getBinaryParserFormat(project);
-	}
-
 	/**
-	 * Set the binaryParser of the Project.
+	 * Return true if project has C++ nature.
 	 */
-	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();
+	public boolean hasCCNature(IProject project){
+		return manager.hasCCNature(project);
 	}
 
 	/**
-	 * Set the default binaryParser.
+	 * 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 void setDefaultBinaryParserFormat(String format) {
-		manager.setDefaultBinaryParserFormat(format);
+	public void resetBinaryParser(IProject project) {
+		manager.resetBinaryParser(project);
 	}
 
 	/**
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.14
diff -u -r1.14 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	26 Feb 2003 21:38:34 -0000	1.14
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	28 Feb 2003 21:23:01 -0000
@@ -20,7 +20,6 @@
 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.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.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 <code>IResourceDelta</code>s into <code>IJavaElementDelta</code>s.
@@ -377,84 +368,126 @@
 		}
 		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 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) {
+//		}
+//	}
 
-	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);
-								}
+	/**
+	 * 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 @@
 			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.SHARED);
 		} catch (IOException e) {
-			//e.printStackTrace();
 		}
 		return false;
 	}
@@ -475,7 +507,6 @@
 			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.OBJECT);
 		} catch (IOException e) {
-			//e.printStackTrace();
 		}
 		return false;
 	}
@@ -500,7 +531,6 @@
 				|| bin.getType() == IBinaryFile.SHARED
 				|| bin.getType() == IBinaryFile.CORE);
 		} catch (IOException e) {
-			//e.printStackTrace();
 		}
 		return false;
 	}
@@ -511,7 +541,6 @@
 			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.ARCHIVE);
 		} catch (IOException e) {
-			//e.printStackTrace();
 		}
 		return false;
 	}
Index: model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java
diff -N model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java	28 Feb 2003 21:23:01 -0000
@@ -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";
+	}
+
+}
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java,v
retrieving revision 1.4
diff -u -r1.4 ElfParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	26 Feb 2003 21:37:33 -0000	1.4
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	28 Feb 2003 21:23:01 -0000
@@ -7,6 +7,7 @@
  
 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 @@
 
 /**
  */
-public class ElfParser implements IBinaryParser {
+public class ElfParser extends AbstractCExtension implements IBinaryParser {
 
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath)
Index: model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java,v
retrieving revision 1.3
diff -u -r1.3 PEParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	26 Feb 2003 21:37:33 -0000	1.3
+++ model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	28 Feb 2003 21:23:01 -0000
@@ -7,6 +7,7 @@
 
 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 @@
 
 /**
  */
-public class PEParser implements IBinaryParser {
+public class PEParser extends AbstractCExtension implements IBinaryParser {
 
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IFile)
Index: src/org/eclipse/cdt/core/CCorePlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java,v
retrieving revision 1.11
diff -u -r1.11 CCorePlugin.java
--- src/org/eclipse/cdt/core/CCorePlugin.java	19 Feb 2003 19:29:04 -0000	1.11
+++ src/org/eclipse/cdt/core/CCorePlugin.java	28 Feb 2003 21:23:01 -0000
@@ -6,14 +6,12 @@
  */
 
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 import org.eclipse.cdt.core.index.IndexModel;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.core.BinaryParserConfiguration;
 import org.eclipse.cdt.internal.core.CDescriptorManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
@@ -32,16 +30,20 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 
-
 public class CCorePlugin extends Plugin {
-	
+
 	public static final int STATUS_CDTPROJECT_EXISTS = 1;
 	public static final int STATUS_CDTPROJECT_MISMATCH = 2;
 	public static final int CDT_PROJECT_NATURE_ID_MISMATCH = 3;
-	
-	public static final String PLUGIN_ID= "org.eclipse.cdt.core";
 
-	public static final String BUILDER_MODEL_ID= PLUGIN_ID + ".CBuildModel";
+	public static final String PLUGIN_ID = "org.eclipse.cdt.core";
+
+	public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel";
+	public static final String BINARY_PARSER_SIMPLE_ID = "BinaryParser";
+	public final static String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID;
+	public final static String PREF_BINARY_PARSER = "binaryparser";
+	public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF";
+	public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID;
 
 	private static CCorePlugin fgCPlugin;
 	private static ResourceBundle fgResourceBundle;
@@ -49,12 +51,14 @@
 	private CDescriptorManager fDescriptorManager;
 
 	// -------- static methods --------
-	
+
 	static {
 		try {
-			fgResourceBundle= ResourceBundle.getBundle("org.eclipse.cdt.internal.CCorePluginResources");
+			fgResourceBundle =
+				ResourceBundle.getBundle(
+					"org.eclipse.cdt.internal.CCorePluginResources");
 		} catch (MissingResourceException x) {
-			fgResourceBundle= null;
+			fgResourceBundle = null;
 		}
 	}
 
@@ -67,50 +71,52 @@
 			return "#" + key + "#";
 		}
 	}
-	
+
 	public static IWorkspace getWorkspace() {
 		return ResourcesPlugin.getWorkspace();
-	}	
-	
+	}
+
 	public static String getFormattedString(String key, String arg) {
-		return MessageFormat.format(getResourceString(key), new String[] { arg });
+		return MessageFormat.format(
+			getResourceString(key),
+			new String[] { arg });
 	}
-	
+
 	public static String getFormattedString(String key, String[] args) {
 		return MessageFormat.format(getResourceString(key), args);
 	}
-	
+
 	public static ResourceBundle getResourceBundle() {
 		return fgResourceBundle;
 	}
-		
+
 	public static CCorePlugin getDefault() {
 		return fgCPlugin;
 	}
-	
+
 	public static void log(Throwable e) {
 		log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e));
 	}
-	
+
 	public static void log(IStatus status) {
-		((Plugin)getDefault()).getLog().log(status);
-	}	
-		
+		((Plugin) getDefault()).getLog().log(status);
+	}
+
 	// ------ CPlugin
 
 	public CCorePlugin(IPluginDescriptor descriptor) {
 		super(descriptor);
-		fgCPlugin= this;
+		fgCPlugin = this;
 	}
-		
+
 	/**
 	 * @see Plugin#shutdown
 	 */
 	public void shutdown() throws CoreException {
 		super.shutdown();
 		fDescriptorManager.shutdown();
-	}		
-	
+	}
+
 	/**
 	 * @see Plugin#startup
 	 */
@@ -127,22 +133,28 @@
 
 	public IConsole getConsole(String id) {
 		try {
-			IExtensionPoint extension = getDescriptor().getExtensionPoint("CBuildConsole");
+			IExtensionPoint extension =
+				getDescriptor().getExtensionPoint("CBuildConsole");
 			if (extension != null) {
-				IExtension[] extensions =  extension.getExtensions();
-				for(int i = 0; i < extensions.length; i++){
-					IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
-					for( int j = 0; j < configElements.length; j++ ) {
-						String builderID = configElements[j].getAttribute("builderID");
-						if ( (id == null && builderID == null) || 
-							 ( id != null && builderID.equals(id))) {
-							return (IConsole)configElements[j].createExecutableExtension("class");
-						 }
+				IExtension[] extensions = extension.getExtensions();
+				for (int i = 0; i < extensions.length; i++) {
+					IConfigurationElement[] configElements =
+						extensions[i].getConfigurationElements();
+					for (int j = 0; j < configElements.length; j++) {
+						String builderID =
+							configElements[j].getAttribute("builderID");
+						if ((id == null && builderID == null)
+							|| (id != null && builderID.equals(id))) {
+							return (
+								IConsole) configElements[j]
+									.createExecutableExtension(
+								"class");
+						}
 					}
 				}
-			}	
+			}
 		} catch (CoreException e) {
-		} 
+		}
 		return new IConsole() {
 			public void clear() {
 			}
@@ -158,41 +170,36 @@
 		return getConsole(null);
 	}
 
-	public IBinaryParserConfiguration[] getBinaryParserConfigurations() {
-		ArrayList list = new ArrayList();
-		IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint("BinaryParser");
-		if (extensionPoint != null) {
-			IExtension[] extensions =  extensionPoint.getExtensions();
-			for(int i = 0; i < extensions.length; i++){
-				IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
-				for( int j = 0; j < configElements.length; j++ ) {
-					String format = configElements[j].getAttribute("format");
-					String name = configElements[j].getAttribute("name");
-					list.add(new BinaryParserConfiguration(format, name));
-				}
-			}
-		}	
-		return (IBinaryParserConfiguration[])list.toArray(new IBinaryParserConfiguration[0]);
-	}
-	
-	public IBinaryParser getBinaryParser(String format) {
+	public IBinaryParser getBinaryParser(IProject project) throws CoreException {
+		IBinaryParser parser = null;
 		try {
-			IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint("BinaryParser");
-			if (extensionPoint != null) {
-				IExtension[] extensions =  extensionPoint.getExtensions();
-				for(int i = 0; i < extensions.length; i++){
-					IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
-					for( int j = 0; j < configElements.length; j++ ) {
-						String attr = configElements[j].getAttribute("format");
-						if (attr != null && attr.equalsIgnoreCase(format)) {
-							return (IBinaryParser)configElements[j].createExecutableExtension("class");
-						}
+			ICDescriptor cdesc = (ICDescriptor) getCProjectDescription(project);
+			ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID);
+			if (cextensions.length > 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 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;
-    }
-
-    /**
-     * 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);
-         } 
-    }
- 
+
+	/**
+	 * 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 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);
+	}
+
+	/**
+	 * 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 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 (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 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;
+	//	}
+
 	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) {
 				}
 			}
 		}
Index: src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
diff -N src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
--- src/org/eclipse/cdt/core/IBinaryParserConfiguration.java	27 Nov 2002 04:47:10 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-package org.eclipse.cdt.core;
-
-
-
-/**
- */
-public interface IBinaryParserConfiguration {
-
-	String getFormat();
-	String getName();
-	IBinaryParser getParser();
-}
Index: src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
diff -N src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
--- src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java	27 Nov 2002 04:47:19 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -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);
-	}
-
-}
Index: src/org/eclipse/cdt/internal/core/CDescriptor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java,v
retrieving revision 1.6
diff -u -r1.6 CDescriptor.java
--- src/org/eclipse/cdt/internal/core/CDescriptor.java	19 Feb 2003 19:29:04 -0000	1.6
+++ src/org/eclipse/cdt/internal/core/CDescriptor.java	28 Feb 2003 21:23:02 -0000
@@ -46,8 +46,6 @@
 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 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 @@
 			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 void remove(String extensionPoint) throws CoreException {
 		CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
 		if (extensions != null) {
-			extMap.put(extensionPoint, null);
+			extMap.remove(extensionPoint);
 			setDirty();
 		}
 	}
Index: src/org/eclipse/cdt/internal/core/CDescriptorManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java,v
retrieving revision 1.8
diff -u -r1.8 CDescriptorManager.java
--- src/org/eclipse/cdt/internal/core/CDescriptorManager.java	19 Feb 2003 19:29:04 -0000	1.8
+++ src/org/eclipse/cdt/internal/core/CDescriptorManager.java	28 Feb 2003 21:23:02 -0000
@@ -88,6 +88,7 @@
 		cproject = (CDescriptor)fDescriptorMap.get(project) ;
 		if ( cproject == null ) {
 			cproject = new CDescriptor(project);
+			cproject.setAutoSave(true);
 			fDescriptorMap.put(project, cproject);
 		}
 		return cproject;



Back to the top