Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java,v retrieving revision 1.12 diff -u -r1.12 MatchLocator2.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java 21 Mar 2003 16:14:08 -0000 1.12 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java 28 Mar 2003 12:11:27 -0000 @@ -781,7 +781,8 @@ this.pattern.initializePolymorphicSearch(this, progressMonitor); IType focusType = getFocusType(); - JavaProject previousJavaProject = focusType == null ? null : (JavaProject)focusType.getJavaProject(); + JavaProject focusProject = focusType == null ? null : (JavaProject)focusType.getJavaProject(); + JavaProject previousJavaProject = null; for (int i = 0; i < length; i++) { if (progressMonitor != null && progressMonitor.isCanceled()) { throw new OperationCanceledException(); @@ -814,10 +815,9 @@ if (resource == null) { // case of a file in an external jar resource = javaProject.getProject(); } - if (focusType == null // when searching in hierarchy, all potential matches are resolved in the focus project context - && !javaProject.equals(previousJavaProject)) { - // locate matches in previous project - if (previousJavaProject != null) { + if (!javaProject.equals(previousJavaProject)) { + // locate matches in previous project if not a prereq of focus project + if (previousJavaProject != null && !preqsProject(focusProject, previousJavaProject)) { try { this.locateMatches(previousJavaProject); } catch (JavaModelException e) { @@ -846,7 +846,7 @@ } // last project - if (previousJavaProject != null) { + if (previousJavaProject != null && !preqsProject(focusProject, previousJavaProject)) { try { this.locateMatches(previousJavaProject); } catch (JavaModelException e) { @@ -859,6 +859,20 @@ this.potentialMatches = new PotentialMatchSet(); } + // focus project + if (focusProject != null) { + try { + this.locateMatches(focusProject); + } catch (JavaModelException e) { + if (e.getException() instanceof CoreException) { + throw e; + } else { + // problem with classpath in last project -> skip it + } + } + this.potentialMatches = new PotentialMatchSet(); + } + if (progressMonitor != null) { progressMonitor.done(); } @@ -922,6 +936,27 @@ } } } + } + /* + * Returns whether the focus project prereqs the given project. + * Returns true if they are the same. + * Returns false if focus project is null. + */ + private boolean preqsProject(JavaProject focusProject, JavaProject project) { + if (focusProject == null) return false; + if (focusProject.equals(project)) return true; + IPath path = project.getPath(); + try { + IClasspathEntry[] resolvedClasspath = focusProject.getResolvedClasspath(true/*ignore unresolved entry*/); + for (int i = 0, length = resolvedClasspath.length; i < length; i++) { + IClasspathEntry entry = resolvedClasspath[i]; + if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && entry.getPath().equals(path)) { + return true; + } + } + } catch (JavaModelException e) { + } + return false; } /* * Process a compilation unit already parsed and build.