diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 8ab15444130..e2523ed1cf6 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,15 @@ +2003-02-19 David Inglis + + * src/org/eclipse/cdt/core/CCorePlugin.java + * src/org/eclipse/cdt/core/ICDescriptor.java + * src/org/eclipse/cdt/core/ICExtensionReference.java + * src/org/eclipse/cdt/core/ICOwner.java + * src/org/eclipse/cdt/internal/core/CDescriptor.java + * src/org/eclipse/cdt/internal/core/CDescriptorManager.java + * src/org/eclipse/cdt/internal/core/CExtensionReference.java + * src/org/eclipse/cdt/internal/core/make/MakeProject.java + General cleanup of CDT extensions interfaces from review with Alain. + 2003-02-17 Doug Schaefer Merged in Sam Robb's source for the build model. The source can be diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index d5691197dd1..d847070e828 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -207,8 +207,12 @@ public class CCorePlugin extends Plugin { return fDescriptorManager.getDescriptor(project); } - public void mapCProjectOwner(IProject project, String id) throws CoreException { - fDescriptorManager.configure(project, id); + public void mapCProjectOwner(IProject project, String id, boolean override) throws CoreException { + if ( !override ) { + fDescriptorManager.configure(project, id); + } else { + fDescriptorManager.convert(project, id); + } } /** @@ -242,7 +246,7 @@ public class CCorePlugin extends Plugin { // Add C Nature ... does not add duplicates CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1)); - mapCProjectOwner(projectHandle, projectID); + mapCProjectOwner(projectHandle, projectID, false); } finally { //monitor.done(); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java index 964b0978c5f..ebaaf38a29f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java @@ -5,13 +5,17 @@ package org.eclipse.cdt.core; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; public interface ICDescriptor { public ICOwnerInfo getProjectOwner(); public String getPlatform(); public IProject getProject(); - public ICExtensionReference[] get(String name); - public ICExtensionReference[] get(String name, boolean update); - public ICExtensionReference create(String name, String id); - public void remove(ICExtensionReference extension); + + public ICExtensionReference[] get(String extensionPoint); + public ICExtensionReference[] get(String extensionPoint, boolean update) throws CoreException; + public ICExtensionReference create(String extensionPoint, String id) throws CoreException; + + public void remove(ICExtensionReference extension) throws CoreException; + public void remove(String extensionPoint) throws CoreException; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java index 0293a346133..9fc9edb04ac 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java @@ -4,9 +4,34 @@ */ package org.eclipse.cdt.core; +import org.eclipse.core.runtime.CoreException; + public interface ICExtensionReference { - public String getExtension(); + + /** + * Return the extension point of this reference. + * @return String + */ + public String getExtension(); + + /** + * Return the extension ID of this reference. + * @return String + */ public String getID(); + + /** + * Sets a name/value data pair on this reference in the .cdtproject file + */ public void setExtensionData(String key, String value); - public String getExtensionData(String key); + + /** + * Gets a value of the key from the .cdtproject file set by setExtensionData() + */ + public String getExtensionData(String key); + + /** + * Creates the executable extension for the reference. + */ + public ICExtension createExtension() throws CoreException; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICOwner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICOwner.java index 33ee00dd437..26b329c1023 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICOwner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICOwner.java @@ -4,7 +4,9 @@ */ package org.eclipse.cdt.core; +import org.eclipse.core.runtime.CoreException; + public interface ICOwner { - public void configure(ICDescriptor cproject); - public void update(ICDescriptor cproject, String extensionID); + public void configure(ICDescriptor cproject) throws CoreException; + public void update(ICDescriptor cproject, String extensionID) throws CoreException; } 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 21a5f3d0496..0f92d9a639c 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 @@ -16,7 +16,6 @@ import java.util.Map.Entry; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import org.apache.xerces.dom.DocumentImpl; import org.apache.xml.serialize.Method; @@ -25,13 +24,18 @@ import org.apache.xml.serialize.Serializer; import org.apache.xml.serialize.SerializerFactory; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.ICExtension; import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.ICOwnerInfo; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IPluginRegistry; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -40,7 +44,6 @@ import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; public class CDescriptor implements ICDescriptor { /* constants */ @@ -49,42 +52,15 @@ public class CDescriptor implements ICDescriptor { private IProject fProject; private HashMap extMap = new HashMap(4); private HashMap extInfoMap = new HashMap(4); - + final static String DESCRIPTION_FILE_NAME = ".cdtproject"; private final static String PROJECT_DESCRIPTION = "cdtproject"; private final static String PROJECT_EXTENSION = "extension"; private final static String PROJECT_EXTENSION_ATTRIBUTE = "attribute"; private boolean fDirty; + private boolean autoSave; - protected void readCDTProject(IPath projectLocation) { - FileInputStream file = null; - try { - file = new FileInputStream(projectLocation.toFile()); - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document document = parser.parse(file); - Node node = document.getFirstChild(); - if (node.getNodeName().equals(PROJECT_DESCRIPTION)) - fOwner = readProjectDescription(node); - } - catch (IOException e) { - } - catch (SAXException e) { - } - catch (ParserConfigurationException e) { - } - finally { - if (file != null) { - try { - file.close(); - } - catch (IOException e) { - } - } - } - - } - protected CDescriptor(IProject project, String id) throws CoreException { fProject = project; IPath projectLocation = project.getDescription().getLocation(); @@ -98,16 +74,28 @@ public class CDescriptor implements ICDescriptor { if (descriptionPath.toFile().exists()) { IStatus status; readCDTProject(descriptionPath); - if ( fOwner.getID().equals(id)) { - status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS, "CDTProject already exisits", (Throwable)null); + if (fOwner.getID().equals(id)) { + status = + new Status( + IStatus.WARNING, + CCorePlugin.PLUGIN_ID, + CCorePlugin.STATUS_CDTPROJECT_EXISTS, + "CDTProject already exisits", + (Throwable) null); } else { - status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_MISMATCH, "CDTProject already exisits but does not match owner ID of creator", (Throwable)null); + status = + new Status( + IStatus.ERROR, + CCorePlugin.PLUGIN_ID, + CCorePlugin.STATUS_CDTPROJECT_MISMATCH, + "CDTProject already exisits but does not match owner ID of creator", + (Throwable) null); } throw new CoreException(status); } fOwner = new COwner(id); } - + protected CDescriptor(IProject project) throws CoreException { fProject = project; IPath projectLocation = project.getDescription().getLocation(); @@ -119,20 +107,67 @@ public class CDescriptor implements ICDescriptor { IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME); if (!descriptionPath.toFile().exists()) { - IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "CDTProject file not found", (Throwable)null); + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "CDTProject file not found", (Throwable) null); throw new CoreException(status); } readCDTProject(descriptionPath); } + protected CDescriptor(IProject project, COwner owner) throws CoreException { + fProject = project; + IPath projectLocation = project.getDescription().getLocation(); + + final boolean isDefaultLocation = projectLocation == null; + if (isDefaultLocation) { + projectLocation = getProjectDefaultLocation(project); + } + IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME); + + if (!descriptionPath.toFile().exists()) { + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "CDTProject file not found", (Throwable) null); + throw new CoreException(status); + } + fOwner = owner; + readProjectExtensions(getCDTProjectNode(descriptionPath)); + } + + protected Node getCDTProjectNode(IPath descriptionPath) throws CoreException { + FileInputStream file = null; + try { + file = new FileInputStream(descriptionPath.toFile()); + DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = parser.parse(file); + Node node = document.getFirstChild(); + if (node.getNodeName().equals(PROJECT_DESCRIPTION)) + return node; + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Missing cdtproject element", null); + throw new CoreException(status); + } catch (Exception e) { + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getLocalizedMessage(), e); + throw new CoreException(status); + } finally { + if (file != null) { + try { + file.close(); + } catch (IOException e) { + } + } + } + } + + protected void readCDTProject(IPath projectLocation) throws CoreException { + Node node = getCDTProjectNode(projectLocation); + fOwner = readProjectDescription(node); + } + protected IPath getProjectDefaultLocation(IProject project) { return Platform.getLocation().append(project.getFullPath()); } - + public ICOwnerInfo getProjectOwner() { return fOwner; } - + public String getPlatform() { return fOwner.getPlatform(); } @@ -144,46 +179,45 @@ public class CDescriptor implements ICDescriptor { public ICExtensionReference[] get(String extensionID) { return (CExtensionReference[]) extMap.get(extensionID); } - + public ICExtensionReference[] get(String extensionID, boolean update) { ICExtensionReference[] ext = get(extensionID); - if ( (ext == null || ext.length == 0) && update) { + if ((ext == null || ext.length == 0) && update) { try { fOwner.update(fProject, this, extensionID); saveInfo(); ext = get(extensionID); - } - catch (CoreException e) { + } catch (CoreException e) { } } return ext; } - public ICExtensionReference create(String name, String id) { - CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(name); - if ( extensions == null ) { + public ICExtensionReference create(String extensionPoint, String extensionID) throws CoreException { + CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint); + if (extensions == null) { extensions = new CExtensionReference[1]; - extMap.put(name, extensions); + extMap.put(extensionPoint, extensions); } else { CExtensionReference[] newExtensions = new CExtensionReference[extensions.length + 1]; System.arraycopy(extensions, 0, newExtensions, 0, extensions.length); extensions = newExtensions; - extMap.put(name, extensions); + extMap.put(extensionPoint, extensions); } setDirty(); - extensions[extensions.length-1] = new CExtensionReference(this, name, id); - return extensions[extensions.length-1]; + extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extensionID); + return extensions[extensions.length - 1]; } - - public void remove(ICExtensionReference ext) { + + public void remove(ICExtensionReference ext) throws CoreException { CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(ext.getExtension()); - for( int i = 0; i < extensions.length; i++ ) { - if ( extensions[i] == ext ) { - System.arraycopy(extensions, i, extensions, i+1, extensions.length - 1 - i); + for (int i = 0; i < extensions.length; i++) { + if (extensions[i] == ext) { + System.arraycopy(extensions, i, extensions, i + 1, extensions.length - 1 - i); CExtensionReference[] newExtensions = new CExtensionReference[extensions.length - 1]; System.arraycopy(extensions, 0, newExtensions, 0, extensions.length); extensions = newExtensions; - if ( extensions.length == 0 ) { + if (extensions.length == 0) { extMap.put(ext.getExtension(), null); } else { extMap.put(ext.getExtension(), extensions); @@ -193,9 +227,17 @@ 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); + setDirty(); + } + } + public CExtensionInfo getInfo(CExtensionReference cProjectExtension) { CExtensionInfo info = (CExtensionInfo) extInfoMap.get(cProjectExtension); - if ( info == null ) { + if (info == null) { info = new CExtensionInfo(); extInfoMap.put(cProjectExtension, info); } @@ -210,52 +252,49 @@ public class CDescriptor implements ICDescriptor { } return null; } - + protected String getString(Node target, String tagName) { Node node = searchNode(target, tagName); return node != null ? (node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue()) : null; } - private COwner readProjectDescription(Node node) { + private COwner readProjectDescription(Node node) throws CoreException { COwner owner = null; NamedNodeMap attrib = node.getAttributes(); - try { - owner = new COwner(attrib.getNamedItem("id").getNodeValue()); - } - catch (CoreException e) { - return null; - } + owner = new COwner(attrib.getNamedItem("id").getNodeValue()); readProjectExtensions(node); return owner; } - private void readProjectExtensions(Node node) { + private void readProjectExtensions(Node node) throws CoreException { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { - if ( list.item(i).getNodeName().equals(PROJECT_EXTENSION) ) { + if (list.item(i).getNodeName().equals(PROJECT_EXTENSION)) { NamedNodeMap attrib = list.item(i).getAttributes(); - ICExtensionReference ext = create(attrib.getNamedItem("point").getNodeValue(), attrib.getNamedItem("id").getNodeValue()); + ICExtensionReference ext = + create(attrib.getNamedItem("point").getNodeValue(), attrib.getNamedItem("id").getNodeValue()); NodeList extAttrib = list.item(i).getChildNodes(); - for( int j = 0; j < extAttrib.getLength(); j++) { - if ( extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE) ) { + for (int j = 0; j < extAttrib.getLength(); j++) { + if (extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE)) { attrib = extAttrib.item(j).getAttributes(); - ext.setExtensionData(attrib.getNamedItem("key").getNodeValue(), attrib.getNamedItem("value").getNodeValue()); + ext.setExtensionData( + attrib.getNamedItem("key").getNodeValue(), + attrib.getNamedItem("value").getNodeValue()); } } - } + } } } - + protected void saveInfo() throws CoreException { String xml; - if ( !isDirty() ) { + if (!isDirty()) { return; } try { xml = getAsXML(); - } - catch (IOException e) { - IStatus s= new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e); + } catch (IOException e) { + IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e); throw new CoreException(s); } @@ -270,24 +309,24 @@ public class CDescriptor implements ICDescriptor { fDirty = false; } - protected void setDirty() { + protected void setDirty() throws CoreException { fDirty = true; + if (isAutoSave()) + saveInfo(); } - + protected boolean isDirty() { return fDirty; } protected String serializeDocument(Document doc) throws IOException { - ByteArrayOutputStream s= new ByteArrayOutputStream(); + ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputFormat format = new OutputFormat(); format.setIndenting(true); - format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$ - - Serializer serializer = - SerializerFactory.getSerializerFactory(Method.XML).makeSerializer( - new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$ - format); + format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$ + + Serializer serializer = SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$ + format); serializer.asDOMSerializer().serialize(doc); return s.toString("UTF8"); //$NON-NLS-1$ } @@ -299,25 +338,50 @@ public class CDescriptor implements ICDescriptor { doc.appendChild(configRootElement); configRootElement.setAttribute("id", fOwner.getID()); //$NON-NLS-1$ Iterator extIterator = extMap.values().iterator(); - while( extIterator.hasNext() ) { + while (extIterator.hasNext()) { CExtensionReference extension[] = (CExtensionReference[]) extIterator.next(); - for( int i = 0; i < extension.length; i ++ ) { + for (int i = 0; i < extension.length; i++) { configRootElement.appendChild(element = doc.createElement(PROJECT_EXTENSION)); element.setAttribute("point", extension[i].getExtension()); element.setAttribute("id", extension[i].getID()); CExtensionInfo info = (CExtensionInfo) extInfoMap.get(extension[i]); - if ( info != null ) { + if (info != null) { Iterator attribIterator = info.getAttributes().entrySet().iterator(); - while( attribIterator.hasNext() ) { + while (attribIterator.hasNext()) { Entry entry = (Entry) attribIterator.next(); Element extAttributes = doc.createElement(PROJECT_EXTENSION_ATTRIBUTE); - extAttributes.setAttribute("key", (String)entry.getKey()); - extAttributes.setAttribute("value", (String)entry.getValue()); + extAttributes.setAttribute("key", (String) entry.getKey()); + extAttributes.setAttribute("value", (String) entry.getValue()); element.appendChild(extAttributes); } } } } return serializeDocument(doc); - } + } + + public boolean isAutoSave() { + return autoSave; + } + + public void setAutoSave(boolean autoSave) { + this.autoSave = autoSave; + } + + protected ICExtension createExtensions(ICExtensionReference ext) throws CoreException { + InternalCExtension cExtension = null; + IPluginRegistry pluginRegistry = Platform.getPluginRegistry(); + IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext.getExtension()); + IExtension extension = extensionPoint.getExtension(ext.getID()); + IConfigurationElement element[] = extension.getConfigurationElements(); + for (int i = 0; i < element.length; i++) { + if (element[i].getName().equalsIgnoreCase("cextension")) { + cExtension = (InternalCExtension) element[i].createExecutableExtension("run"); + cExtension.setExtenionReference(ext); + cExtension.setProject(fProject); + break; + } + } + return (ICExtension) cExtension; + } } 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 5264cb0920f..18ef07bfe9a 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 @@ -4,13 +4,10 @@ */ package org.eclipse.cdt.internal.core; -import java.util.ArrayList; import java.util.HashMap; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; -import org.eclipse.cdt.core.ICExtension; -import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -20,14 +17,7 @@ import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPluginRegistry; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; public class CDescriptorManager implements IResourceChangeListener { @@ -128,52 +118,43 @@ public class CDescriptorManager implements IResourceChangeListener { COwner cowner = new COwner(id); cowner.configure(project, cproject); cproject.saveInfo(); + cproject.setAutoSave(true); fDescriptorMap.put(project, cproject); } + public synchronized void convert(IProject project, String id) throws CoreException { + CDescriptor cproject; + if ( fDescriptorMap == null ) { + fDescriptorMap = new HashMap(); + } + COwner cowner = new COwner(id); + cproject = new CDescriptor(project, cowner); + cowner.configure(project, cproject); + cproject.saveInfo(); + cproject.setAutoSave(true); + fDescriptorMap.put(project, cproject); + } - public ICExtension[] createExtensions(String extensionID, IProject project) throws CoreException { - ArrayList extensionList = new ArrayList(1); - ICDescriptor cDescriptor = getDescriptor(project); - ICExtensionReference ext[] = cDescriptor.get(extensionID, true); - IPluginRegistry pluginRegistry = Platform.getPluginRegistry(); - for( int i = 0; i < ext.length; i++ ) { - IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext[i].getExtension()); - IExtension extension = extensionPoint.getExtension(ext[i].getID()); - IConfigurationElement element[] = extension.getConfigurationElements(); - for( int j = 0; j < element.length; j++ ) { - if ( element[j].getName().equalsIgnoreCase("run") ) { - InternalCExtension cExtension = (InternalCExtension) element[i].createExecutableExtension("class"); - cExtension.setExtenionReference(ext[i]); - cExtension.setProject(project); - extensionList.add(cExtension); - break; - } - } - } - return (ICExtension[]) extensionList.toArray(new ICExtension[extensionList.size()]); - } - - /** + /** * Must remove an existing .cdtproject file before we generate a new one when converting */ - public static void removeExistingCdtProjectFile(IProject project){ - IFile file = project.getFile(CDescriptor.DESCRIPTION_FILE_NAME); - IProgressMonitor monitor = new NullProgressMonitor(); - - // update the resource content - if ((file != null) && file.exists()) { - try{ - file.delete(true, monitor); - // remove reference from the fDescriptorMap - if (fDescriptorMap != null){ - fDescriptorMap.remove(project); - } - - project.refreshLocal(1, monitor); - }catch(CoreException ce){ - CCorePlugin.log(ce); - } - } - } +// public static void removeExistingCdtProjectFile(IProject project){ +// IFile file = project.getFile(CDescriptor.DESCRIPTION_FILE_NAME); +// IProgressMonitor monitor = new NullProgressMonitor(); +// +// // update the resource content +// if ((file != null) && file.exists()) { +// try{ +// file.delete(true, monitor); +// // remove reference from the fDescriptorMap +// if (fDescriptorMap != null){ +// fDescriptorMap.remove(project); +// } +// +// project.refreshLocal(1, monitor); +// }catch(CoreException ce){ +// CCorePlugin.log(ce); +// } +// } +// } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java index f3d00d43829..0ac1bd67faf 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java @@ -4,7 +4,9 @@ */ package org.eclipse.cdt.internal.core; +import org.eclipse.cdt.core.ICExtension; import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.core.runtime.CoreException; public class CExtensionReference implements ICExtensionReference { private CDescriptor fDescriptor; @@ -36,5 +38,9 @@ public class CExtensionReference implements ICExtensionReference { public String getExtensionData(String key) { return getInfo().getAttribute(key); } + + public ICExtension createExtension() throws CoreException { + return fDescriptor.createExtensions(this); + } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/make/MakeProject.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/make/MakeProject.java index 2acedf99250..f2e0e09ae0d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/make/MakeProject.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/make/MakeProject.java @@ -8,15 +8,17 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.ICOwner; +import org.eclipse.core.runtime.CoreException; public class MakeProject implements ICOwner { - public void configure(ICDescriptor cproject) { + public void configure(ICDescriptor cproject) throws CoreException { + cproject.remove(CCorePlugin.BUILDER_MODEL_ID); ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, CCorePlugin.PLUGIN_ID + ".makeBuilder"); ext.setExtensionData("command", "make"); } - public void update(ICDescriptor cproject, String extensionID) { + public void update(ICDescriptor cproject, String extensionID) throws CoreException { if ( extensionID.equals(CCorePlugin.BUILDER_MODEL_ID ) ) { ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, CCorePlugin.PLUGIN_ID + ".makeBuilder"); ext.setExtensionData("command", "make"); diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 9364c77841d..d40c191e01f 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,8 @@ +2003-02-19 David Inglis + * src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java + * src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java + Due to CDT extensions interface cleanup. + 2003-02-17 Doug Schaefer Merged in Sam Robb's source for the build model. The source can be diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java index 6b3fedf03b8..7b45d645b27 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java @@ -124,11 +124,12 @@ public abstract class ConversionWizard * * @see org.eclipse.cdt.ui.wizards.CProjectWizard#doRun(IProgressMonitor) */ - protected void doRun(IProgressMonitor monitor) { + protected void doRun(IProgressMonitor monitor) throws CoreException { try{ mainPage.doRun(monitor, getProjectID()); } catch (CoreException ce){ CCorePlugin.log(ce); + throw ce; } finally{ doRunEpilogue(monitor); monitor.isCanceled(); @@ -138,9 +139,7 @@ public abstract class ConversionWizard * Return the type of project that it is being converted to * The default if a make project */ - public String getProjectID() { - return CCorePlugin.PLUGIN_ID + ".make";//$NON-NLS-1$ - } + public abstract String getProjectID(); /** * Method addPages allows subclasses to add as many pages as they need. Overwrite diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java index b36f22bae46..e5a9ca1ea54 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java @@ -5,6 +5,7 @@ package org.eclipse.cdt.ui.wizards.conversion; * All Rights Reserved. */ +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.ui.CUIPlugin; /** @@ -85,4 +86,8 @@ public class ConvertToStdMakeConversionWizard extends ConversionWizard { addPage(mainPage); } + + public String getProjectID() { + return CCorePlugin.PLUGIN_ID + ".make";//$NON-NLS-1$ + } }