View | Details | Raw Unified | Return to bug 35755 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java (-6 / +41 lines)
Lines 781-787 Link Here
781
			this.pattern.initializePolymorphicSearch(this, progressMonitor);
781
			this.pattern.initializePolymorphicSearch(this, progressMonitor);
782
			
782
			
783
			IType focusType = getFocusType();
783
			IType focusType = getFocusType();
784
			JavaProject previousJavaProject = focusType == null ? null : (JavaProject)focusType.getJavaProject();
784
			JavaProject focusProject = focusType == null ? null : (JavaProject)focusType.getJavaProject();
785
			JavaProject previousJavaProject = null;
785
			for (int i = 0; i < length; i++) {
786
			for (int i = 0; i < length; i++) {
786
				if (progressMonitor != null && progressMonitor.isCanceled()) {
787
				if (progressMonitor != null && progressMonitor.isCanceled()) {
787
					throw new OperationCanceledException();
788
					throw new OperationCanceledException();
Lines 814-823 Link Here
814
					if (resource == null) { // case of a file in an external jar
815
					if (resource == null) { // case of a file in an external jar
815
						resource = javaProject.getProject();
816
						resource = javaProject.getProject();
816
					}
817
					}
817
					if (focusType == null // when searching in hierarchy, all potential matches are resolved in the focus project context
818
					if (!javaProject.equals(previousJavaProject)) {
818
							&& !javaProject.equals(previousJavaProject)) {
819
						// locate matches in previous project if not a prereq of focus project
819
						// locate matches in previous project
820
						if (previousJavaProject != null && !preqsProject(focusProject, previousJavaProject)) {
820
						if (previousJavaProject != null) {
821
							try {
821
							try {
822
								this.locateMatches(previousJavaProject);
822
								this.locateMatches(previousJavaProject);
823
							} catch (JavaModelException e) {
823
							} catch (JavaModelException e) {
Lines 846-852 Link Here
846
			}
846
			}
847
			
847
			
848
			// last project
848
			// last project
849
			if (previousJavaProject != null) {
849
			if (previousJavaProject != null && !preqsProject(focusProject, previousJavaProject)) {
850
				try {
850
				try {
851
					this.locateMatches(previousJavaProject);
851
					this.locateMatches(previousJavaProject);
852
				} catch (JavaModelException e) {
852
				} catch (JavaModelException e) {
Lines 859-864 Link Here
859
				this.potentialMatches = new PotentialMatchSet();
859
				this.potentialMatches = new PotentialMatchSet();
860
			} 
860
			} 
861
			
861
			
862
			// focus project
863
			if (focusProject != null) {
864
				try {
865
					this.locateMatches(focusProject);
866
				} catch (JavaModelException e) {
867
					if (e.getException() instanceof CoreException) {
868
						throw e;
869
					} else {
870
						// problem with classpath in last project -> skip it
871
					}
872
				}
873
				this.potentialMatches = new PotentialMatchSet();
874
			}
875
			
862
			if (progressMonitor != null) {
876
			if (progressMonitor != null) {
863
				progressMonitor.done();
877
				progressMonitor.done();
864
			}
878
			}
Lines 922-927 Link Here
922
					}
936
					}
923
				}
937
				}
924
			}
938
			}
939
	}
940
	/*
941
	 * Returns whether the focus project prereqs the given project.
942
	 * Returns true if they are the same.
943
	 * Returns false if focus project is null.
944
	 */
945
	private boolean preqsProject(JavaProject focusProject, JavaProject project) {
946
		if (focusProject == null) return false;
947
		if (focusProject.equals(project)) return true;
948
		IPath path = project.getPath();
949
		try {
950
			IClasspathEntry[] resolvedClasspath = focusProject.getResolvedClasspath(true/*ignore unresolved entry*/);
951
			for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
952
				IClasspathEntry entry = resolvedClasspath[i];
953
				if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && entry.getPath().equals(path)) {
954
					return true;
955
				}
956
			}
957
		} catch (JavaModelException e) {
958
		}
959
		return false;
925
	}
960
	}
926
	/*
961
	/*
927
	 * Process a compilation unit already parsed and build.
962
	 * Process a compilation unit already parsed and build.

Return to bug 35755