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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+54 lines)
Lines 15-20 Link Here
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
18
import org.eclipse.core.resources.IncrementalProjectBuilder;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
Lines 7858-7861 Link Here
7858
	// Should have same types with these 2 searches
7859
	// Should have same types with these 2 searches
7859
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
7860
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
7860
}
7861
}
7862
7863
/**
7864
 * @bug 178847 [search] Potential matches found when searching references to IJavaElement#getResource()
7865
 * @test Ensure that accurate matches are found
7866
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=178847"
7867
 */
7868
public void testBug178847() throws CoreException {
7869
	try {
7870
		createJavaProject("P1", new String[] {"src" }, "bin");
7871
		createFolder("/P1/src/p");
7872
		createFile(
7873
			"/P1/src/p/X.java",
7874
			"package p;\n" +
7875
			"public class X{\n" +
7876
			"}"
7877
		);
7878
		createFile(
7879
			"/P1/src/p/Y.java",
7880
			"package p;\n" +
7881
			"public class Y extends X {\n" +
7882
			"  public static void foo() {}\n" +
7883
			"}"
7884
		);
7885
		getProject("P1").build(IncrementalProjectBuilder.FULL_BUILD, null);
7886
		deleteFile("/P1/bin/p/X.class");
7887
		createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB", "/P1/bin"}, "");
7888
		workingCopies = new ICompilationUnit[2];
7889
		workingCopies[0] = getWorkingCopy("/P2/Test1.java",
7890
			"public class Test1 {\n" + 
7891
			"  void bar() {\n" + 
7892
			"    p.Y.foo();\n" + 
7893
			"    new p.X();\n" + // cause AbortCompilation here
7894
			"  }\n" + 
7895
			"}"
7896
		);
7897
		workingCopies[1] = getWorkingCopy("/P2/Test2.java",
7898
			"public class Test2 {\n" + 
7899
			"  void foo() {}\n" +
7900
			"  void bar() {\n" +
7901
			"    foo();\n" +
7902
			"  }\n" +
7903
			"}"
7904
		);
7905
		IMethod method = workingCopies[1].getType("Test2").getMethod("foo", new String[0]);
7906
		search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), resultCollector);
7907
		assertSearchResults(
7908
			"Test2.java void Test2.bar() [foo()] EXACT_MATCH"
7909
		);
7910
	} finally {
7911
		deleteProjects(new String[] {"P1", "P2" });
7912
	}
7913
}
7914
7861
}
7915
}
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (-1 / +1 lines)
Lines 31-37 Link Here
31
/**
31
/**
32
 * Abstract class for Java Search tests.
32
 * Abstract class for Java Search tests.
33
 */
33
 */
34
public class AbstractJavaSearchTests extends AbstractJavaModelTests implements IJavaSearchConstants {
34
public class AbstractJavaSearchTests extends ModifyingResourceTests implements IJavaSearchConstants {
35
35
36
	public static List JAVA_SEARCH_SUITES = null;
36
	public static List JAVA_SEARCH_SUITES = null;
37
	protected static IJavaProject JAVA_PROJECT;
37
	protected static IJavaProject JAVA_PROJECT;
(-)src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java (+3 lines)
Lines 25-30 Link Here
25
public ModifyingResourceTests(String name) {
25
public ModifyingResourceTests(String name) {
26
	super(name);
26
	super(name);
27
}
27
}
28
public ModifyingResourceTests(String name, int tabs) {
29
	super(name, tabs);
30
}
28
protected void assertElementDescendants(String message,  String expected, IJavaElement element) throws CoreException {
31
protected void assertElementDescendants(String message,  String expected, IJavaElement element) throws CoreException {
29
	String actual = expandAll(element);
32
	String actual = expandAll(element);
30
	if (!expected.equals(actual)){
33
	if (!expected.equals(actual)){

Return to bug 178847