Bug 546723 - speed up resource lookup for workspace members
Reordered source lookup strategies so that the fastest checks are tried
first. Skip lookup of containers when searching for an archive.
getResource() for a workspace member no longer has to search for linked
resources in the whole workspace.
Change-Id: I5424f3490844c6ee803ed39ae13b1b343694a885
Signed-off-by: Julian Honnen <julian.honnen@vector.com>
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
index fc579c2..f5def68 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
@@ -352,21 +352,41 @@
protected IResource getResource(IPath path) {
if (path != null) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if (getType() == PROJECT) {
+ // project entry should always have a workspace relative path, try the fastest lookup first
+ IResource member = root.findMember(path);
+ if (member != null) {
+ return member;
+ }
+ }
+
// look for files or folders with the given path
+ IFile file = root.getFileForLocation(path);
+ if (file != null) {
+ return file;
+ }
+ if (getType() != ARCHIVE) {
+ IContainer container = root.getContainerForLocation(path);
+ if (container != null) {
+ return container;
+ }
+ }
+
@SuppressWarnings("deprecation")
IFile[] files = root.findFilesForLocation(path);
if (files.length > 0) {
return files[0];
}
- @SuppressWarnings("deprecation")
- IContainer[] containers = root.findContainersForLocation(path);
- if (containers.length > 0) {
- return containers[0];
+
+ if (getType() != ARCHIVE) {
+ @SuppressWarnings("deprecation")
+ IContainer[] containers = root.findContainersForLocation(path);
+ if (containers.length > 0) {
+ return containers[0];
+ }
}
- if (path.getDevice() == null) {
- // search relative to the workspace if no device present
- return root.findMember(path);
- }
+
+ return root.findMember(path);
}
return null;
}