Index: search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java,v retrieving revision 1.42 diff -u -r1.42 JavaSearchScope.java --- search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 14 Jun 2005 16:33:53 -0000 1.42 +++ search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 22 Jun 2005 11:18:32 -0000 @@ -306,25 +306,34 @@ for (int i = 0, length = this.paths.length; i < length; i++) { String scopePath = this.paths[i]; if (scopePath == null) continue; - if (encloses(this.containerPaths[i] + '/' + scopePath, relativePath, i)) + if (scopePath.length() == 0) + scopePath = this.containerPaths[i]; + else + scopePath = this.containerPaths[i] + '/' + scopePath; + if (encloses(scopePath, relativePath, i)) return i; } return -1; } private boolean encloses(String scopePath, String path, int index) { + int pathLength = path.length(); + int scopeLength = scopePath.length(); + if (pathLength < scopeLength) return false; + if (scopeLength == 0) return true; + if (pathLength == scopeLength) { + return path.equals(scopePath); + } if (this.pathWithSubFolders[index]) { if (path.startsWith(scopePath)) { - return true; + return path.charAt(scopeLength) == '/'; } } else { // if not looking at subfolders, this scope encloses the given path // if this path is a direct child of the scope's ressource // or if this path is the scope's resource (see bug 13919 Declaration for package not found if scope is not project) - if (path.startsWith(scopePath) - && ((scopePath.length() == path.lastIndexOf('/')) - || (scopePath.length() == path.length()))) { - return true; + if (path.startsWith(scopePath)) { + return path.lastIndexOf('/') == scopeLength; } } return false;