From 6a5352c615be8b6b1fee67f7b7439972a3a4ee38 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 8 Oct 2003 20:10:23 +0000 Subject: [PATCH] Fallback to a search on the project. --- .../internal/ui/editor/OpenIncludeAction.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java index cf070c4a7bc..c4dd2af9d3d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java @@ -23,6 +23,8 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceProxy; +import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -83,7 +85,8 @@ public class OpenIncludeAction extends Action { if (info != null) { String[] includePaths = info.getIncludePaths(); findFile(includePaths, includeName, filesFound); - } else { + } + if (filesFound.size() == 0) { // Fall back and search the project findFile(proj, new Path(includeName), filesFound); } @@ -125,17 +128,24 @@ public class OpenIncludeAction extends Action { } } - private void findFile(IContainer parent, IPath name, ArrayList list) throws CoreException { - IResource found= parent.findMember(name); - if (found != null && found.getType() == IResource.FILE) { - list.add(found.getLocation()); - } - IResource[] children= parent.members(); - for (int i= 0; i < children.length; i++) { - if (children[i] instanceof IContainer) { - findFile((IContainer)children[i], name, list); + /** + * Recuse in the project. + * @param parent + * @param name + * @param list + * @throws CoreException + */ + private void findFile(IContainer parent, final IPath name, final ArrayList list) throws CoreException { + parent.accept(new IResourceProxyVisitor() { + + public boolean visit(IResourceProxy proxy) throws CoreException { + if (proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase(name.lastSegment())) { + list.add(proxy.requestResource().getLocation()); + return false; + } + return true; } - } + }, 0); }