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

(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (+10 lines)
Lines 375-380 Link Here
375
			throw e; // want to abort enclosing request to compile
375
			throw e; // want to abort enclosing request to compile
376
		}
376
		}
377
	}
377
	}
378
	// Display unit error in debug mode
379
	if (BasicSearchEngine.VERBOSE) {
380
		if (unitResult.problemCount > 0) {
381
			System.out.println(unitResult);
382
		}
383
	}
378
}
384
}
379
/**
385
/**
380
 * Add additional source types
386
 * Add additional source types
Lines 948-953 Link Here
948
	this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, this.nameEnvironment);
954
	this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, this.nameEnvironment);
949
955
950
	this.parser = MatchLocatorParser.createParser(problemReporter, this);
956
	this.parser = MatchLocatorParser.createParser(problemReporter, this);
957
	
958
	// basic parser needs also to be reset as project options may have changed
959
	// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=163072
960
	this.basicParser = null;
951
961
952
	// remember project's name lookup
962
	// remember project's name lookup
953
	this.nameLookup = searchableEnvironment.nameLookup;
963
	this.nameLookup = searchableEnvironment.nameLookup;
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java (+72 lines)
Lines 793-796 Link Here
793
		deleteProject("P2");
793
		deleteProject("P2");
794
	}
794
	}
795
}
795
}
796
797
/**
798
 * @bug 163072: [search] method reference reports wrong potential matches
799
 * @test Ensure that there's no potential match while searching in two projects having 1.4 and 1.5 compliances
800
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=163072"
801
 */
802
public void testONLY_Bug163072() throws CoreException {
803
	try {
804
		// setup project P1
805
		/*IJavaProject p1 = */createJavaProject("P1"); // standard project using 1.4 compliance
806
		createFolder("/P1/test");
807
		createFile(
808
			"/P1/test/Test.java",
809
			"package test;\n" + 
810
			"public class Test {\n" + 
811
			"	public Object getType() {\n" + 
812
			"		return null;\n" + 
813
			"	}\n" + 
814
			"	public void foo() {\n" + 
815
			"		if (getType() == null) {\n" + 
816
			"			System.out.println(\"null\");\n" + 
817
			"		}\n" + 
818
			"	}\n" + 
819
			"}\n"
820
		);
821
822
		// setup project P2
823
		createJavaProject("P2", new String[] {""}, new String[] {"JCL15_LIB"}, new String[] { "/P1" }, "", "1.5");
824
		createFolder("/P2/pack");
825
		createFile(
826
			"/P2/pack/FactoryContainer.java",
827
			"package pack;\n" + 
828
			"public class FactoryContainer {\n" + 
829
			"	public enum FactoryType { PLUGIN }\n" + 
830
			"	public FactoryType getType() {\n" + 
831
			"		return FactoryType.PLUGIN;\n" + 
832
			"	}\n" + 
833
			"}\n"
834
		);
835
		createFile(
836
			"/P2/pack/Reference.java",
837
			"package pack;\n" + 
838
			"public class Reference {\n" + 
839
			"	private final FactoryContainer _fc;\n" + 
840
			"	public Reference() {\n" + 
841
			"		_fc = new FactoryContainer();\n" + 
842
			"	}\n" + 
843
			"	boolean foo() {\n" + 
844
			"		return _fc.getType() == FactoryContainer.FactoryType.PLUGIN;\n" + 
845
			"	}\n" + 
846
			"}\n"
847
		);
848
849
		// Get method
850
		IMethod method = getCompilationUnit("/P1/test/Test.java").getType("Test").getMethod("getType", new String[0]);
851
		assertTrue("Method 'Test.getType()' should exist!", method.exists());
852
853
		// search method declaration in workspace scope
854
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2});
855
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
856
		resultCollector.showProject = true;
857
		resultCollector.showAccuracy = true;
858
		search(method, REFERENCES, scope, resultCollector);
859
		assertSearchResults(
860
			"Unexpected references of method Test.getType()",
861
			"test/Test.java [in P1] void test.Test.foo() [getType()] EXACT_MATCH",
862
			resultCollector);
863
	} finally {
864
		deleteProject("P1");
865
		deleteProject("P2");
866
	}
867
}
796
}
868
}

Return to bug 163072