1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

IBinary speed up

CDescriptor fix #43533
CExtension - null removes attributes
This commit is contained in:
David Inglis 2003-09-24 13:55:26 +00:00
parent 18e0534368
commit 366e74c5bc
4 changed files with 63 additions and 36 deletions

View file

@ -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

View file

@ -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() {
@ -85,6 +77,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()) {
return ((IBinaryObject)binaryFile).getText();

View file

@ -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")) {

View file

@ -21,7 +21,11 @@ public class CExtensionInfo {
}
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) {