Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Head: OpenIncludeAction fall back

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.204
diff -u -r1.204 ChangeLog
--- ChangeLog	8 Oct 2003 19:04:15 -0000	1.204
+++ ChangeLog	8 Oct 2003 20:08:37 -0000
@@ -1,5 +1,13 @@
 2003-10-08 Alain Magloire
 
+	For Open on the header do a fallback and look for the header
+	in the project.  This code should be revisit once, the
+	CPathEntry and the ScannerInfoProvider are getting smarter.
+
+	* src/org/eclipse/cdt/internal/ui/OpenIncludeAction.java
+
+2003-10-08 Alain Magloire
+
 	Do selection better for Binary objects,  the binary
 	elements do not have offset information but only line number.
 	We can leverage, by looking at the offset corresponding to
Index: src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java,v
retrieving revision 1.7
diff -u -r1.7 OpenIncludeAction.java
--- src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java	28 Aug 2003 19:47:01 -0000	1.7
+++ src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java	8 Oct 2003 20:08:38 -0000
@@ -23,6 +23,8 @@
 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 @@
 					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 @@
 		}
 	}
 
-	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);
 	}
 
 



Back to the top