diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 3bc0cebedb7..12e4165c63f 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,14 @@ +2003-09-24 David Inglis + + * src/org/eclipse/cdt/internal/core/CExtensionInfo.java + null should removed attributes. + + * src/org/eclipse/cdt/internal/core/CDescriptor.java + Fixed bug# 43533 + + * model/org/eclipse/cdt/internal/core/model/Binary.java + Help with slow IBinary interface. + 2003-09-22 Bogdan Gheorghe Took out old CTags code from CCorePlugin diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index acbebb57c0b..043108c2bdb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -24,6 +24,10 @@ import org.eclipse.core.runtime.Path; public class Binary extends Openable implements IBinary { + private int fBinType; + + private long fLastModification; + IBinaryFile binaryFile; public Binary(ICElement parent, IFile file, IBinaryFile bin) { @@ -37,31 +41,19 @@ public class Binary extends Openable implements IBinary { } public boolean isSharedLib() { - if (binaryFile != null) { - return binaryFile.getType() == IBinaryObject.SHARED; - } - return false; + return getType() == IBinaryObject.SHARED; } public boolean isExecutable() { - if (binaryFile != null) { - return binaryFile.getType() == IBinaryObject.EXECUTABLE; - } - return false; + return getType() == IBinaryObject.EXECUTABLE; } public boolean isObject() { - if (binaryFile != null) { - return binaryFile.getType() == IBinaryObject.OBJECT; - } - return false; + return getType() == IBinaryObject.OBJECT; } public boolean isCore() { - if (binaryFile != null) { - return binaryFile.getType() == IBinaryObject.CORE; - } - return false; + return getType() == IBinaryObject.CORE; } public boolean hasDebug() { @@ -84,6 +76,15 @@ public class Binary extends Openable implements IBinary { } return new String[0]; } + + protected int getType() { + IResource res = getResource(); + if (binaryFile != null && (fBinType == 0 || res.getModificationStamp() != fLastModification )) { + fLastModification = res.getModificationStamp(); + fBinType = binaryFile.getType(); + } + return fBinType; + } public long getText() { if (isObject() || isExecutable() || isSharedLib()) { 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 2055c0a02ba..d8de5615422 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 @@ -80,8 +80,7 @@ public class CDescriptor implements ICDescriptor { fProject = project; IPath projectLocation = project.getDescription().getLocation(); - final boolean isDefaultLocation = projectLocation == null; - if (isDefaultLocation) { + if (projectLocation == null) { projectLocation = getProjectDefaultLocation(project); } IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME); @@ -116,8 +115,7 @@ public class CDescriptor implements ICDescriptor { fProject = project; IPath projectLocation = project.getDescription().getLocation(); - final boolean isDefaultLocation = projectLocation == null; - if (isDefaultLocation) { + if (projectLocation == null) { projectLocation = getProjectDefaultLocation(project); } IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME); @@ -133,8 +131,7 @@ public class CDescriptor implements ICDescriptor { fProject = project; IPath projectLocation = project.getDescription().getLocation(); - final boolean isDefaultLocation = projectLocation == null; - if (isDefaultLocation) { + if (projectLocation == null) { projectLocation = getProjectDefaultLocation(project); } IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME); @@ -160,7 +157,13 @@ public class CDescriptor implements ICDescriptor { Document document = parser.parse(file); Node node = document.getFirstChild(); if (node.getNodeName().equals(PROJECT_DESCRIPTION)) { - return readProjectDescription(node); + String ownerID = node.getAttributes().getNamedItem("id").getNodeValue(); + if ( ownerID != null) { + readProjectDescription(node); + return ownerID; + } + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Missing owner id", null); + throw new CoreException(status); } IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Missing cdtproject element", null); throw new CoreException(status); @@ -316,30 +319,35 @@ public class CDescriptor implements ICDescriptor { return s.toString("UTF8"); //$NON-NLS-1$ } - private String readProjectDescription(Node node) throws CoreException { + private void readProjectDescription(Node node) { Node childNode; ArrayList pathEntries = new ArrayList(); - String ownerID = node.getAttributes().getNamedItem("id").getNodeValue(); NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { childNode = list.item(i); - if ( childNode.getNodeType() == Node.ELEMENT_NODE ) { + if (childNode.getNodeType() == Node.ELEMENT_NODE) { if (childNode.getNodeName().equals(PROJECT_EXTENSION)) { - //decodeProjectExtension((Element)node); - decodeProjectExtension((Element)childNode); + try { + decodeProjectExtension((Element) childNode); + } catch (CoreException e) { + CCorePlugin.log(e); + } } else if (childNode.getNodeName().equals(PATH_ENTRY)) { - //ICPathEntry entry = decodePathEntry((Element)node); - ICPathEntry entry = decodePathEntry((Element)childNode); - if (entry != null) { - pathEntries.add(entry); + try { + pathEntries.add(decodePathEntry((Element) childNode)); + } catch (CoreException e) { + CCorePlugin.log(e); } } else if (childNode.getNodeName().equals(PROJECT_DATA)) { - decodeProjectData((Element)childNode); + try { + decodeProjectData((Element)childNode); + } catch (CoreException e) { + CCorePlugin.log(e); + } } } } fPathEntries = (ICPathEntry[]) pathEntries.toArray(new ICPathEntry[0]); - return ownerID; } private void decodeProjectExtension(Element element) throws CoreException { @@ -542,6 +550,9 @@ public class CDescriptor implements ICDescriptor { IPluginRegistry pluginRegistry = Platform.getPluginRegistry(); IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext.getExtension()); IExtension extension = extensionPoint.getExtension(ext.getID()); + if ( extension == null) { + throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Extension provider not found.", null)); + } IConfigurationElement element[] = extension.getConfigurationElements(); for (int i = 0; i < element.length; i++) { if (element[i].getName().equalsIgnoreCase("cextension")) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java index e4fd954eed0..7d9e146bb91 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java @@ -15,13 +15,17 @@ import java.util.HashMap; public class CExtensionInfo { protected HashMap attribMap = new HashMap(4); - + protected HashMap getAttributes() { return attribMap; } public void setAttribute(String key, String value) { - attribMap.put(key, value); + if (value == null) { + attribMap.remove(key); + } else { + attribMap.put(key, value); + } } public String getAttribute(String key) {