View | Details | Raw Unified | Return to bug 211962
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java (+62 lines)
Lines 14-24 Link Here
14
14
15
import junit.framework.Test;
15
import junit.framework.Test;
16
16
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
19
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.search.*;
23
import org.eclipse.jdt.core.search.*;
21
import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector;
24
import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector;
25
import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.TypeNameMatchCollector;
26
import org.eclipse.jdt.core.tests.util.Util;
22
27
23
/**
28
/**
24
 * Tests the Java search engine accross multiple projects.
29
 * Tests the Java search engine accross multiple projects.
Lines 918-921 Link Here
918
		deleteProject("P");
923
		deleteProject("P");
919
	}
924
	}
920
}
925
}
926
927
/**
928
 * @bug 211962: [search] NullPointerException when typing search pattern in open type
929
 * @test Ensure that no NPE occurs when an internal JAR file of a non-Java project
930
 *		has the same path than an external JAR file which is on a Java project classpath
931
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=211962"
932
 */
933
public void testBug211962() throws CoreException, IOException {
934
	IPath tmpPath = new Path(getExternalPath()).append("b211962");
935
	try {
936
		// Create external JAR file
937
		tmpPath.toFile().mkdir();
938
		IPath externalLibPath = tmpPath.append("lib.jar");
939
		String[] pathsAndContents = new String[] {
940
			"p/X.java",
941
			"package p;\n" +
942
			"public class X {}"
943
		};
944
		Util.createJar(pathsAndContents, externalLibPath.toString(), "1.4");
945
946
		// Create simple project with internal JAR file
947
		IProject p1 = createProject(tmpPath.segment(0));
948
		IPath folderPath = new Path(p1.getName());
949
		for (int i=1,max=tmpPath.segmentCount(); i<max; i++) {
950
			folderPath = folderPath.append(tmpPath.segment(i));
951
			createFolder(folderPath.toString());
952
		}
953
		IPath internalLibPath = p1.getParent().getLocation().append(folderPath).append("lib.jar");
954
		Util.createJar(pathsAndContents, internalLibPath.toString(), "1.4");
955
		p1.refreshLocal(IResource.DEPTH_INFINITE, null);
956
957
		// Create java project
958
		String libPath = externalLibPath.setDevice(null).toString();
959
		IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB", libPath }, "bin");
960
961
		// Search all type names with TypeNameMatchRequestor
962
		TypeNameMatchCollector collector = new TypeNameMatchCollector();
963
		new SearchEngine().searchAllTypeNames(
964
			null,
965
			SearchPattern.R_EXACT_MATCH,
966
			new char[] { 'X' },
967
			SearchPattern.R_PREFIX_MATCH,
968
			IJavaSearchConstants.TYPE,
969
			SearchEngine.createJavaSearchScope(new IJavaElement[] { p2 }),
970
			collector,
971
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
972
			null);
973
		assertSearchResults(
974
			"X (not open) [in X.class [in p [in "+libPath+" [in P2]]]]",
975
			collector
976
		);
977
	} finally {
978
		Util.delete(tmpPath.toString());
979
		deleteProject(tmpPath.segment(0));
980
		deleteProject("P2");
981
	}
982
}
921
}
983
}
(-)buildnotes_jdt-core.html (-1 / +3 lines)
Lines 54-60 Link Here
54
<h2>What's new in this drop</h2>
54
<h2>What's new in this drop</h2>
55
55
56
<h3>Problem Reports Fixed</h3>
56
<h3>Problem Reports Fixed</h3>
57
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=212769">212769</a>
57
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211962">211962</a>
58
[search] NullPointerException when typing search pattern in open type
59
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=212769">212769</a>
58
SetClasspathOperation no longer adds project for refresh
60
SetClasspathOperation no longer adds project for refresh
59
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211718">211718</a>
61
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211718">211718</a>
60
[1.5][compiler] compiler error with nested enum in class using generics
62
[1.5][compiler] compiler error with nested enum in class using generics
(-)search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java (-1 / +3 lines)
Lines 586-592 Link Here
586
			}
586
			}
587
			if (target instanceof IResource) {
587
			if (target instanceof IResource) {
588
				IJavaElement element = JavaCore.create((IResource)target);
588
				IJavaElement element = JavaCore.create((IResource)target);
589
				return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
589
				if (element != null) {
590
					return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
591
				}
590
			}
592
			}
591
			if (isJarFile) {
593
			if (isJarFile) {
592
				return project.getPackageFragmentRoot(this.containerPaths[index]);
594
				return project.getPackageFragmentRoot(this.containerPaths[index]);

Return to bug 211962