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:
parent
18e0534368
commit
366e74c5bc
4 changed files with 63 additions and 36 deletions
|
@ -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
|
2003-09-22 Bogdan Gheorghe
|
||||||
|
|
||||||
Took out old CTags code from CCorePlugin
|
Took out old CTags code from CCorePlugin
|
||||||
|
|
|
@ -24,6 +24,10 @@ import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class Binary extends Openable implements IBinary {
|
public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
|
private int fBinType;
|
||||||
|
|
||||||
|
private long fLastModification;
|
||||||
|
|
||||||
IBinaryFile binaryFile;
|
IBinaryFile binaryFile;
|
||||||
|
|
||||||
public Binary(ICElement parent, IFile file, IBinaryFile bin) {
|
public Binary(ICElement parent, IFile file, IBinaryFile bin) {
|
||||||
|
@ -37,31 +41,19 @@ public class Binary extends Openable implements IBinary {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSharedLib() {
|
public boolean isSharedLib() {
|
||||||
if (binaryFile != null) {
|
return getType() == IBinaryObject.SHARED;
|
||||||
return binaryFile.getType() == IBinaryObject.SHARED;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExecutable() {
|
public boolean isExecutable() {
|
||||||
if (binaryFile != null) {
|
return getType() == IBinaryObject.EXECUTABLE;
|
||||||
return binaryFile.getType() == IBinaryObject.EXECUTABLE;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isObject() {
|
public boolean isObject() {
|
||||||
if (binaryFile != null) {
|
return getType() == IBinaryObject.OBJECT;
|
||||||
return binaryFile.getType() == IBinaryObject.OBJECT;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCore() {
|
public boolean isCore() {
|
||||||
if (binaryFile != null) {
|
return getType() == IBinaryObject.CORE;
|
||||||
return binaryFile.getType() == IBinaryObject.CORE;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDebug() {
|
public boolean hasDebug() {
|
||||||
|
@ -84,6 +76,15 @@ public class Binary extends Openable implements IBinary {
|
||||||
}
|
}
|
||||||
return new String[0];
|
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() {
|
public long getText() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
|
|
@ -80,8 +80,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
IPath projectLocation = project.getDescription().getLocation();
|
IPath projectLocation = project.getDescription().getLocation();
|
||||||
|
|
||||||
final boolean isDefaultLocation = projectLocation == null;
|
if (projectLocation == null) {
|
||||||
if (isDefaultLocation) {
|
|
||||||
projectLocation = getProjectDefaultLocation(project);
|
projectLocation = getProjectDefaultLocation(project);
|
||||||
}
|
}
|
||||||
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
||||||
|
@ -116,8 +115,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
IPath projectLocation = project.getDescription().getLocation();
|
IPath projectLocation = project.getDescription().getLocation();
|
||||||
|
|
||||||
final boolean isDefaultLocation = projectLocation == null;
|
if (projectLocation == null) {
|
||||||
if (isDefaultLocation) {
|
|
||||||
projectLocation = getProjectDefaultLocation(project);
|
projectLocation = getProjectDefaultLocation(project);
|
||||||
}
|
}
|
||||||
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
||||||
|
@ -133,8 +131,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
IPath projectLocation = project.getDescription().getLocation();
|
IPath projectLocation = project.getDescription().getLocation();
|
||||||
|
|
||||||
final boolean isDefaultLocation = projectLocation == null;
|
if (projectLocation == null) {
|
||||||
if (isDefaultLocation) {
|
|
||||||
projectLocation = getProjectDefaultLocation(project);
|
projectLocation = getProjectDefaultLocation(project);
|
||||||
}
|
}
|
||||||
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
||||||
|
@ -160,7 +157,13 @@ public class CDescriptor implements ICDescriptor {
|
||||||
Document document = parser.parse(file);
|
Document document = parser.parse(file);
|
||||||
Node node = document.getFirstChild();
|
Node node = document.getFirstChild();
|
||||||
if (node.getNodeName().equals(PROJECT_DESCRIPTION)) {
|
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);
|
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Missing cdtproject element", null);
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
|
@ -316,30 +319,35 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return s.toString("UTF8"); //$NON-NLS-1$
|
return s.toString("UTF8"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readProjectDescription(Node node) throws CoreException {
|
private void readProjectDescription(Node node) {
|
||||||
Node childNode;
|
Node childNode;
|
||||||
ArrayList pathEntries = new ArrayList();
|
ArrayList pathEntries = new ArrayList();
|
||||||
String ownerID = node.getAttributes().getNamedItem("id").getNodeValue();
|
|
||||||
NodeList list = node.getChildNodes();
|
NodeList list = node.getChildNodes();
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
for (int i = 0; i < list.getLength(); i++) {
|
||||||
childNode = list.item(i);
|
childNode = list.item(i);
|
||||||
if ( childNode.getNodeType() == Node.ELEMENT_NODE ) {
|
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
if (childNode.getNodeName().equals(PROJECT_EXTENSION)) {
|
if (childNode.getNodeName().equals(PROJECT_EXTENSION)) {
|
||||||
//decodeProjectExtension((Element)node);
|
try {
|
||||||
decodeProjectExtension((Element)childNode);
|
decodeProjectExtension((Element) childNode);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
} else if (childNode.getNodeName().equals(PATH_ENTRY)) {
|
} else if (childNode.getNodeName().equals(PATH_ENTRY)) {
|
||||||
//ICPathEntry entry = decodePathEntry((Element)node);
|
try {
|
||||||
ICPathEntry entry = decodePathEntry((Element)childNode);
|
pathEntries.add(decodePathEntry((Element) childNode));
|
||||||
if (entry != null) {
|
} catch (CoreException e) {
|
||||||
pathEntries.add(entry);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
} else if (childNode.getNodeName().equals(PROJECT_DATA)) {
|
} 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]);
|
fPathEntries = (ICPathEntry[]) pathEntries.toArray(new ICPathEntry[0]);
|
||||||
return ownerID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decodeProjectExtension(Element element) throws CoreException {
|
private void decodeProjectExtension(Element element) throws CoreException {
|
||||||
|
@ -542,6 +550,9 @@ public class CDescriptor implements ICDescriptor {
|
||||||
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
||||||
IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext.getExtension());
|
IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext.getExtension());
|
||||||
IExtension extension = extensionPoint.getExtension(ext.getID());
|
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();
|
IConfigurationElement element[] = extension.getConfigurationElements();
|
||||||
for (int i = 0; i < element.length; i++) {
|
for (int i = 0; i < element.length; i++) {
|
||||||
if (element[i].getName().equalsIgnoreCase("cextension")) {
|
if (element[i].getName().equalsIgnoreCase("cextension")) {
|
||||||
|
|
|
@ -15,13 +15,17 @@ import java.util.HashMap;
|
||||||
public class CExtensionInfo {
|
public class CExtensionInfo {
|
||||||
|
|
||||||
protected HashMap attribMap = new HashMap(4);
|
protected HashMap attribMap = new HashMap(4);
|
||||||
|
|
||||||
protected HashMap getAttributes() {
|
protected HashMap getAttributes() {
|
||||||
return attribMap;
|
return attribMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttribute(String key, String value) {
|
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) {
|
public String getAttribute(String key) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue