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 |
} |